Package uk.org.ogsadai.activity

Examples of uk.org.ogsadai.activity.MockOutputPipe


                "def flush()\n" +
                "  Java::java.util.Collections.emptyList;\n" +
                "end\n";
        MockInputPipe scriptInput = new MockInputPipe(script);
        MockInputPipe languageInput = new MockInputPipe("jruby");
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        GenericTupleTransformActivity activity = new GenericTupleTransformActivity();
        activity.addInput(GenericTupleTransformActivity.INPUT_DATA, dataInput);
        activity.addInput(GenericTupleTransformActivity.INPUT_SCRIPT, scriptInput);
        activity.addInput(GenericTupleTransformActivity.INPUT_LANGUAGE, languageInput);
        activity.addOutput(GenericTupleTransformActivity.OUTPUT, output);
        activity.process();
        List<?> actual = output.getActualBlocks();
        Assert.assertEquals(1, ((Tuple)actual.get(2)).getInt(0));
        Assert.assertEquals(5, ((Tuple)actual.get(3)).getInt(0));
        Assert.assertEquals(9, ((Tuple)actual.get(4)).getInt(0));
    }
View Full Code Here


                new SimpleTuple(Arrays.asList(2, "e")),
                ControlBlock.LIST_END
        });
        MockInputPipe scriptInput = new MockInputPipe(GenericTupleJoinActivityTest.readFile("src/ogsadai/test/uk/org/ogsadai/generic/ReplaceNull.rb"));
        MockInputPipe languageInput = new MockInputPipe("jruby");
        MockOutputPipe output = new MockOutputPipe(new Object[]{});
        GenericTupleTransformActivity activity = new GenericTupleTransformActivity();
        activity.addInput(GenericTupleTransformActivity.INPUT_DATA, dataInput);
        activity.addInput(GenericTupleTransformActivity.INPUT_SCRIPT, scriptInput);
        activity.addInput(GenericTupleTransformActivity.INPUT_LANGUAGE, languageInput);
        activity.addOutput(GenericTupleTransformActivity.OUTPUT, output);
        activity.process();
        List<?> actual = output.getActualBlocks();
        Assert.assertEquals(0, ((Tuple)actual.get(2)).getInt(0));
        Assert.assertEquals(0, ((Tuple)actual.get(3)).getInt(0));
        Assert.assertEquals(1, ((Tuple)actual.get(4)).getInt(0));
        Assert.assertEquals(1, ((Tuple)actual.get(5)).getInt(0));
        Assert.assertEquals(2, ((Tuple)actual.get(6)).getInt(0));
View Full Code Here

                ControlBlock.LIST_END
        });
        String script = readFile("src/ogsadai/test/uk/org/ogsadai/generic/SoundexJoin.rb");
        MockInputPipe scriptInput = new MockInputPipe(script);
        MockInputPipe languageInput = new MockInputPipe("jruby");
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        GenericTupleJoinActivity activity = new GenericTupleJoinActivity();
        activity.addInput(GenericTupleJoinActivity.INPUT_DATA1, data1Input);
        activity.addInput(GenericTupleJoinActivity.INPUT_DATA2, data2Input);
        activity.addInput(GenericTupleJoinActivity.INPUT_SCRIPT, scriptInput);
        activity.addInput(GenericTupleJoinActivity.INPUT_LANGUAGE, languageInput);
        activity.addOutput(GenericTupleJoinActivity.OUTPUT, output);
        activity.process();
        List<?> actual = output.getActualBlocks();
        Assert.assertEquals("Rupert", ((Tuple)actual.get(2)).getString(0));
        Assert.assertEquals("Robert", ((Tuple)actual.get(2)).getString(1));
        Assert.assertEquals("Ally", ((Tuple)actual.get(3)).getString(0));
        Assert.assertEquals("Ali", ((Tuple)actual.get(3)).getString(1));
        Assert.assertEquals("Amy", ((Tuple)actual.get(4)).getString(0));
View Full Code Here

       
        ListSplitActivity activity = new ListSplitActivity();
        activity.addInput(ListSplitActivity.INPUT_SIZE, inputSize);
        activity.addInput(ListSplitActivity.INPUT_DATA, inputData);
       
        MockOutputPipe output = new MockOutputPipe(
                new Object[] {});
        activity.addOutput(ListSplitActivity.OUTPUT_RESULT, output);
       
        activity.process();
        System.out.println(output.getActualBlocks());
    }
View Full Code Here

       
        StringReplaceActivity activity = new StringReplaceActivity();
        activity.addInput(StringReplaceActivity.INPUT_TEMPLATE, inputTemplate);
        activity.addInput(StringReplaceActivity.INPUT_DATA, inputData);
       
        MockOutputPipe output = new MockOutputPipe(
                new Object[] {"Hello Amy, hello 0!",
                              "Hello Ally, hello 1.0!",
                              "Hello Radek, hello 2.0!"});
        activity.addOutput(StringReplaceActivity.OUTPUT_RESULT, output);
       
        activity.process();
        output.verify();
       
    }
View Full Code Here

       
        StringReplaceActivity activity = new StringReplaceActivity();
        activity.addInput(StringReplaceActivity.INPUT_TEMPLATE, inputTemplate);
        activity.addInput(StringReplaceActivity.INPUT_DATA, inputData);
       
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(StringReplaceActivity.OUTPUT_RESULT, output);
       
        try
        {
            activity.process();
View Full Code Here

                ControlBlock.LIST_BEGIN, "yes", "no", ControlBlock.LIST_END,
                ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierActivity.INPUT_NOMINAL_VALUES, nominalValuesInput);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierActivity.CLASSIFIER_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);
        MockInputPipe inputResultColumnName = new MockInputPipe("myResult");
        classify.addInput(ClassifyActivity.INPUT_RESULT_COLUMN_NAME, inputResultColumnName);
        MockOutputPipe outputClassify = new MockOutputPipe(new Object[] {});
        classify.addOutput(ClassifyActivity.OUTPUT, outputClassify);
       
        classify.process();
       
        List<?> actualBlocks = outputClassify.getActualBlocks();
        assertEquals(input.size(), actualBlocks.size());
        TupleMetadata tupleMetadata = (TupleMetadata)((MetadataWrapper)actualBlocks.get(1)).getMetadata();
        assertEquals("myResult", tupleMetadata.getColumnMetadata(0).getName());
        assertEquals(ControlBlock.LIST_BEGIN, actualBlocks.get(0));
        for (int i=2; i<actualBlocks.size()-1; i++)
View Full Code Here

                ControlBlock.LIST_BEGIN, "yes", "no", ControlBlock.LIST_END,
                ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierActivity.INPUT_NOMINAL_VALUES, nominalValuesInput);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierActivity.CLASSIFIER_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);
        MockInputPipe inputResultColumnName = new MockInputPipe("myResult");
        classify.addInput(ClassifyActivity.INPUT_RESULT_COLUMN_NAME, inputResultColumnName);
        MockOutputPipe outputClassify = new MockOutputPipe(new Object[] {});
        classify.addOutput(ClassifyActivity.OUTPUT, outputClassify);
       
        classify.process();
       
        List<?> actualBlocks = outputClassify.getActualBlocks();
        assertEquals(input.size(), actualBlocks.size());
        TupleMetadata tupleMetadata = (TupleMetadata)((MetadataWrapper)actualBlocks.get(1)).getMetadata();
        assertEquals("myResult", tupleMetadata.getColumnMetadata(0).getName());
        assertEquals(ControlBlock.LIST_BEGIN, actualBlocks.get(0));
        for (int i=2; i<actualBlocks.size()-1; i++)
View Full Code Here

                ControlBlock.LIST_BEGIN, "yes", "no", ControlBlock.LIST_END,
                ControlBlock.LIST_END
        });
        activity.addInput(BuildClassifierActivity.INPUT_NOMINAL_VALUES, nominalValuesInput);

        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        activity.addOutput(BuildClassifierActivity.CLASSIFIER_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(table.toArray());
        classify.addInput(ClassifyActivity.INPUT_DATA, inputData);
        MockOutputPipe outputClassify = new MockOutputPipe(new Object[] {});
        classify.addOutput(ClassifyActivity.OUTPUT, outputClassify);
       
        classify.process();
       
        List actualBlocks = outputClassify.getActualBlocks();
        assertEquals(table.size(), actualBlocks.size());
        assertEquals(ControlBlock.LIST_BEGIN, actualBlocks.get(0));
        for (int i=2; i<actualBlocks.size()-1; i++)
        {
            assertEquals("Unexpected class",
View Full Code Here

            "Some other test string",
            new SimpleTuple(Arrays.asList(1, 2, 3, 4, 5))
        };
        MockInputPipe input = new MockInputPipe(data);
        serialiser.addInput(SerialiserActivity.INPUT_DATA, input);
        MockOutputPipe output = new MockOutputPipe(new Object[] {});
        serialiser.addOutput(SerialiserActivity.OUTPUT_RESULT, output);
        serialiser.process();
        MockInputPipe input2 = new MockInputPipe(output.getActualBlocks().toArray());
        DeserialiserActivity deserialiser = new DeserialiserActivity();
        deserialiser.addInput(DeserialiserActivity.INPUT_DATA, input2);
        MockOutputPipe output2 = new MockOutputPipe(data);
        deserialiser.addOutput(DeserialiserActivity.OUTPUT_RESULT, output2);
        deserialiser.process();
    }   
View Full Code Here

TOP

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

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.