use of org.apache.storm.streams.processors.FilterProcessor in project storm by apache.
the class ProcessorBoltTest method testEmitAndAck.
@Test
public void testEmitAndAck() throws Exception {
setUpProcessorBolt(new FilterProcessor<Integer>(x -> true));
bolt.execute(mockTuple1);
ArgumentCaptor<Collection> anchor = ArgumentCaptor.forClass(Collection.class);
ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
ArgumentCaptor<String> os = ArgumentCaptor.forClass(String.class);
Mockito.verify(mockOutputCollector).emit(os.capture(), anchor.capture(), values.capture());
assertEquals("outputstream", os.getValue());
assertArrayEquals(new Object[] { mockTuple1 }, anchor.getValue().toArray());
assertEquals(new Values(100), values.getValue());
Mockito.verify(mockOutputCollector, Mockito.times(1)).ack(mockTuple1);
}
use of org.apache.storm.streams.processors.FilterProcessor in project storm by apache.
the class ProcessorBoltTest method testEmitTs.
@Test
public void testEmitTs() throws Exception {
Tuple tupleWithTs = Mockito.mock(Tuple.class);
setUpMockTuples(tupleWithTs);
Mockito.when(tupleWithTs.getLongByField("ts")).thenReturn(12345L);
setUpProcessorBolt(new FilterProcessor(x -> true), "ts");
bolt.execute(tupleWithTs);
ArgumentCaptor<Collection> anchor = ArgumentCaptor.forClass(Collection.class);
ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
ArgumentCaptor<String> os = ArgumentCaptor.forClass(String.class);
Mockito.verify(mockOutputCollector).emit(os.capture(), anchor.capture(), values.capture());
assertEquals("outputstream", os.getValue());
assertArrayEquals(new Object[] { tupleWithTs }, anchor.getValue().toArray());
assertEquals(new Values(100, 12345L), values.getValue());
Mockito.verify(mockOutputCollector, Mockito.times(1)).ack(tupleWithTs);
}
Aggregations