Search in sources :

Example 1 with LongSum

use of org.apache.storm.streams.operations.aggregators.LongSum in project storm by apache.

the class ProcessorBoltTest method testAggResultAndAck.

@Test
public void testAggResultAndAck() throws Exception {
    setUpProcessorBolt(new AggregateProcessor<>(new LongSum()), Collections.singleton("inputstream"), true, null);
    bolt.execute(mockTuple2);
    bolt.execute(mockTuple3);
    bolt.execute(punctuation);
    ArgumentCaptor<Collection> anchor = ArgumentCaptor.forClass(Collection.class);
    ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
    ArgumentCaptor<String> os = ArgumentCaptor.forClass(String.class);
    Mockito.verify(mockOutputCollector, Mockito.times(2)).emit(os.capture(), anchor.capture(), values.capture());
    assertArrayEquals(new Object[] { mockTuple2, mockTuple3, punctuation }, anchor.getAllValues().get(0).toArray());
    assertArrayEquals(new Object[] { mockTuple2, mockTuple3, punctuation }, anchor.getAllValues().get(1).toArray());
    assertArrayEquals(new Object[] { new Values(200L), new Values("__punctuation") }, values.getAllValues().toArray());
    assertArrayEquals(new Object[] { "outputstream", "outputstream__punctuation" }, os.getAllValues().toArray());
    Mockito.verify(mockOutputCollector).ack(mockTuple2);
    Mockito.verify(mockOutputCollector).ack(mockTuple3);
    Mockito.verify(mockOutputCollector).ack(punctuation);
}
Also used : Values(org.apache.storm.tuple.Values) Collection(java.util.Collection) LongSum(org.apache.storm.streams.operations.aggregators.LongSum) Test(org.junit.Test)

Aggregations

Collection (java.util.Collection)1 LongSum (org.apache.storm.streams.operations.aggregators.LongSum)1 Values (org.apache.storm.tuple.Values)1 Test (org.junit.Test)1