Package uk.org.ogsadai.activity

Examples of uk.org.ogsadai.activity.MockInputPipe


    {
        FilterActivity activity = new FilterActivity();
       
        Tuple tuple1 = createTuple(new Object[] {1, 3});
        Tuple tuple2 = createTuple(new Object[] {-4, 8});
        MockInputPipe dataInput = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        createTupleMetadata(),
                        tuple1,
                        createTuple(new Object[] {5, 1}),
                        tuple2,
                        createTuple(new Object[] {6, -5}),
                        ControlBlock.LIST_END });
        MockInputPipe expressionInput = new MockInputPipe("X < Y AND Y + X = 4");
        activity.addInput("data", dataInput);
        activity.addInput("expression", expressionInput);
       
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput("output", output);
View Full Code Here


        Tuple tupleTrue2 = createTuple(new Object[] {4, 5});
        Tuple tupleTrue3 = createTuple(new Object[] {10, 100});
       
        Tuple tupleFalse1 = createTuple(new Object[] {5, 1});
        Tuple tupleFalse2 = createTuple(new Object[] {6, -5});
        MockInputPipe dataInput = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        createTupleMetadata(),
                        tupleTrue1,
                        tupleFalse1,
                        tupleTrue2,
                        tupleFalse2,
                        tupleTrue3,
                        ControlBlock.LIST_END });
        MockInputPipe expressionInput = new MockInputPipe("X < Y");
        activity.addInput("data", dataInput);
        activity.addInput("expression", expressionInput);
       
        MockOutputPipe outputTrue = new MockOutputPipe(new Object[] {});
        activity.addOutput("true", outputTrue);
View Full Code Here

    {
        PostToHTTPActivity activity = new PostToHTTPActivity();
       
        String content = "Hello, this is a test.";
        String host = "http://admire4.epcc.ed.ac.uk:8080/AdmireRepository/";
        MockInputPipe urlInput = new MockInputPipe(host);
        MockInputPipe dataInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN,
                content.getBytes(),
                ControlBlock.LIST_END
        });
        activity.addInput(PostToHTTPActivity.INPUT_URL, urlInput);
        activity.addInput(PostToHTTPActivity.INPUT_DATA, dataInput);
       
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(PostToHTTPActivity.OUTPUT, output);
       
        activity.process();
        String filename = (String)output.getActualBlocks().get(0);
       
        GetFromHTTPActivity get = new GetFromHTTPActivity();
        get.addInput(GetFromHTTPActivity.INPUT_URL, new MockInputPipe(host));
        get.addInput(GetFromHTTPActivity.INPUT_FILENAME, new MockInputPipe(filename));
        MockOutputPipe data = new MockOutputPipe(new Object[] {});
        get.addOutput(GetFromHTTPActivity.OUTPUT, data);
       
        get.process();
       
View Full Code Here

                BuildClassifierMultiInputActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.J48");
        activity.configureActivity(properties);

        List<Object> input = buildInputTable();
        MockInputPipe dataInput = new MockInputPipe(input.toArray());
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {4});
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe nominalColumnsInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, 0, 1, 4, ControlBlock.LIST_END });
        activity.addInput(
                BuildClassifierMultiInputActivity.INPUT_COLUMN_INDICES,
                nominalColumnsInput);

        MockInputPipe nominalValuesInput0 = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "sunny", "overcast", "rain", ControlBlock.LIST_END
        });
        MockInputPipe nominalValuesInput1 = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "true", "false", ControlBlock.LIST_END
        });
        MockInputPipe nominalValuesInput4 = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "yes", "no", ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_NOMINAL_VALUES, nominalValuesInput0);
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_NOMINAL_VALUES, nominalValuesInput1);
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_NOMINAL_VALUES, nominalValuesInput4);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierMultiInputActivity.OUTPUT, output);
       
        activity.process();
       
        TupleClassifier classifier = (TupleClassifier)output.getActualBlocks().get(0);
        System.out.println(classifier);
       
        ClassifyActivity classify = new ClassifyActivity();
        MockInputPipe inputClassifier = new MockInputPipe(classifier);
        classify.addInput(ClassifyActivity.INPUT_CLASSIFIER, inputClassifier);
        MockInputPipe inputData = new MockInputPipe(buildInputTable().toArray());
        classify.addInput(ClassifyActivity.INPUT_DATA, inputData);
        MockOutputPipe outputClassify = new MockOutputPipe(new Object[] {});
        classify.addOutput(ClassifyActivity.OUTPUT, outputClassify);
       
        classify.process();
View Full Code Here

                BuildClassifierMultiInputActivity.CLASSIFIER_CLASS_NAME,
                "weka.classifiers.trees.J48");
        activity.configureActivity(properties);

        List<Object> input = buildInputTable();
        MockInputPipe dataInput = new MockInputPipe(input.toArray());
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_DATA, dataInput);
       
        MockInputPipe classIndexInput = new MockInputPipe(new Object[] {4});
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_CLASS_INDEX, classIndexInput);

        MockInputPipe nominalColumnsInput = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "outlook", "windy", "play", ControlBlock.LIST_END });
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_COLUMN_INDICES, nominalColumnsInput);

        MockInputPipe nominalValuesInput0 = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "sunny", "overcast", "rain", ControlBlock.LIST_END
        });
        MockInputPipe nominalValuesInput1 = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "true", "false", ControlBlock.LIST_END
        });
        MockInputPipe nominalValuesInput4 = new MockInputPipe(new Object[] {
                ControlBlock.LIST_BEGIN, "yes", "no", ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_NOMINAL_VALUES, nominalValuesInput0);
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_NOMINAL_VALUES, nominalValuesInput1);
        activity.addInput(BuildClassifierMultiInputActivity.INPUT_NOMINAL_VALUES, nominalValuesInput4);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierMultiInputActivity.OUTPUT, output);
       
        activity.process();
       
        TupleClassifier classifier = (TupleClassifier)output.getActualBlocks().get(0);
        System.out.println(classifier);
       
        ClassifyActivity classify = new ClassifyActivity();
        MockInputPipe inputClassifier = new MockInputPipe(classifier);
        classify.addInput(ClassifyActivity.INPUT_CLASSIFIER, inputClassifier);
        MockInputPipe inputData = new MockInputPipe(buildInputTable().toArray());
        classify.addInput(ClassifyActivity.INPUT_DATA, inputData);
        MockOutputPipe outputClassify = new MockOutputPipe(new Object[] {});
        classify.addOutput(ClassifyActivity.OUTPUT, outputClassify);
       
        classify.process();
View Full Code Here

        cdlist.add(new SimpleColumnMetadata("cust_id", TupleTypes._INT, 0, 0, 11));
        cdlist.add(new SimpleColumnMetadata("items_bought", TupleTypes._STRING, 0, 0, 11));
        SimpleTupleMetadata metadata = new SimpleTupleMetadata(cdlist);
       
        ConversionActivity activity = new ConversionActivity();
        MockInputPipe input = new MockInputPipe( new Object[] {
                ControlBlock.LIST_BEGIN,
                new MetadataWrapper(metadata),
                new SimpleTuple(Arrays.asList(new Object[] {1, "30"})),
                new SimpleTuple(Arrays.asList(new Object[] {1, "90"})),
                new SimpleTuple(Arrays.asList(new Object[] {2, "10 20"})),
View Full Code Here

        TestBlockReader input = new TestBlockReader(TUPLE_COUNT);
        input.setTupleFactory(new SimpleTupleFactory());
        input.setTupleMetadata(metadata);
        SortActivity activity = new SortActivity();
        activity.addInput("data", input);
        MockInputPipe columns = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        new Integer(0),
                        ControlBlock.LIST_END});
        activity.addInput("columns", columns);
View Full Code Here

        TestBlockReader input = new TestBlockReader(TUPLE_COUNT);
        input.setTupleFactory(new SimpleTupleFactory());
        input.setTupleMetadata(metadata);
        SortActivity activity = new SortActivity();
        activity.addInput("data", input);
        MockInputPipe columns = new MockInputPipe(
                new Object[] {
                        ControlBlock.LIST_BEGIN,
                        new Integer(1),
                        new Integer(0),
                        ControlBlock.LIST_END});
View Full Code Here

        TestBlockReader input = new TestBlockReader(TUPLE_COUNT);
        input.setTupleFactory(new SimpleTupleFactory());
        input.setTupleMetadata(metadata);
        SortActivity activity = new SortActivity();
        activity.addInput("data", input);
        MockInputPipe columns = new MockInputPipe(
                new Object[] {
                        new Integer(1),
                        new Integer(0)
                        });
        activity.addInput("columns", columns);
View Full Code Here

        TestBlockReader input = new TestBlockReader(TUPLE_COUNT);
        input.setTupleFactory(new SimpleTupleFactory());
        input.setTupleMetadata(metadata);
        SortActivity activity = new SortActivity();
        activity.addInput("data", input);
        MockInputPipe columns = new MockInputPipe(
                new Object[] {ControlBlock.LIST_BEGIN, "A", "B", ControlBlock.LIST_END});
        activity.addInput("columns", columns);
        TestBlockWriter output =
            new TestBlockWriter(TUPLE_COUNT, new int[] {1, 0});
        activity.addOutput("data", output);
View Full Code Here

TOP

Related Classes of uk.org.ogsadai.activity.MockInputPipe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.