use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class ArrayListToItemTest method testNodeProcessing.
/**
* Test operator pass through. The Object passed is not relevant
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testNodeProcessing() throws Exception {
ArrayListToItem oper = new ArrayListToItem();
CountTestSink itemSink = new CountTestSink();
oper.item.setSink(itemSink);
oper.beginWindow(0);
ArrayList<String> input = new ArrayList<String>();
input.add("a");
// 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, itemSink.count);
}
use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class CounterTest method testNodeProcessing.
/**
* Test oper pass through. The Object passed is not relevant
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testNodeProcessing() throws Exception {
Counter oper = new Counter();
CountTestSink cSink = new CountTestSink();
oper.output.setSink(cSink);
int numtuples = 100;
oper.beginWindow(0);
for (int i = 0; i < numtuples; i++) {
oper.input.process(i);
}
oper.endWindow();
oper.beginWindow(1);
for (int i = 0; i < numtuples; i++) {
oper.input.process(i);
}
oper.endWindow();
Assert.assertEquals("number emitted tuples", 2, cSink.getCount());
}
use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class StreamMergerTest method testNodeProcessing.
/**
* Test oper pass through. The Object passed is not relevant
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testNodeProcessing() throws Exception {
StreamMerger oper = new StreamMerger();
CountTestSink mergeSink = new CountTestSink();
oper.out.setSink(mergeSink);
oper.beginWindow(0);
int numtuples = 500;
Integer input = 0;
// Same input object can be used as the oper is just pass through
for (int i = 0; i < numtuples; i++) {
oper.data1.process(input);
oper.data2.process(input);
}
oper.endWindow();
Assert.assertEquals("number emitted tuples", numtuples * 2, mergeSink.count);
}
use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class SamplerTest method testNodeProcessing.
/**
* Test node logic emits correct results
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testNodeProcessing() throws Exception {
Sampler<String> oper = new Sampler<String>();
CountTestSink sink = new CountTestSink<String>();
oper.sample.setSink(sink);
oper.setSamplingPercentage(.1);
String tuple = "a";
int numTuples = 10000;
oper.beginWindow(0);
for (int i = 0; i < numTuples; i++) {
oper.data.process(tuple);
}
oper.endWindow();
int lowerlimit = 5;
int upperlimit = 15;
int actual = (100 * sink.count) / numTuples;
Assert.assertEquals("number emitted tuples", true, lowerlimit < actual);
Assert.assertEquals("number emitted tuples", true, upperlimit > actual);
}
use of org.apache.apex.malhar.lib.testbench.CountTestSink in project apex-malhar by apache.
the class KeyPairToHashMapTest method testNodeProcessing.
/**
* Test oper pass through. The Object passed is not relevant
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testNodeProcessing() throws Exception {
KeyValPairToHashMap oper = new KeyValPairToHashMap();
CountTestSink mapSink = new CountTestSink();
oper.map.setSink(mapSink);
oper.beginWindow(0);
KeyValPair<String, String> input = new KeyValPair<String, String>("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.keyval.process(input);
}
oper.endWindow();
Assert.assertEquals("number emitted tuples", numtuples, mapSink.count);
}
Aggregations