use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class HashMapToKeyValPairTest method testNodeProcessing.
/**
* Test oper pass through. The Object passed is not relevant
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testNodeProcessing() throws Exception {
HashMapToKeyValPair oper = new HashMapToKeyValPair();
CountTestSink keySink = new CountTestSink();
CountTestSink valSink = new CountTestSink();
CountTestSink keyvalSink = new CountTestSink();
oper.key.setSink(keySink);
oper.val.setSink(valSink);
oper.keyval.setSink(keyvalSink);
oper.beginWindow(0);
HashMap<String, String> input = new HashMap<String, String>();
input.put("a", "1");
// Same input object can be used as the oper is just pass through
int numtuples = 1000;
for (int i = 0; i < numtuples; i++) {
oper.data.process(input);
}
oper.endWindow();
Assert.assertEquals("number emitted tuples", numtuples, keySink.count);
Assert.assertEquals("number emitted tuples", numtuples, valSink.count);
Assert.assertEquals("number emitted tuples", numtuples, keyvalSink.count);
}
use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class StreamDuplicaterTest method testNodeProcessing.
/**
* Test oper pass through. The Object passed is not relevant
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testNodeProcessing() throws Exception {
StreamDuplicater oper = new StreamDuplicater();
CountTestSink mergeSink1 = new CountTestSink();
CountTestSink mergeSink2 = new CountTestSink();
oper.out1.setSink(mergeSink1);
oper.out2.setSink(mergeSink2);
oper.beginWindow(0);
int numtuples = 1000;
Integer input = 0;
// Same input object can be used as the oper is just pass through
for (int i = 0; i < numtuples; i++) {
oper.data.process(input);
}
oper.endWindow();
// One for each key
Assert.assertEquals("number emitted tuples", numtuples, mergeSink1.count);
Assert.assertEquals("number emitted tuples", numtuples, mergeSink2.count);
}
Aggregations