use of org.apache.storm.tuple.Tuple in project storm by apache.
the class ProcessorBoltTest method setUpMockTuples.
private void setUpMockTuples(Tuple... tuples) {
for (Tuple tuple : tuples) {
Mockito.when(tuple.size()).thenReturn(1);
Mockito.when(tuple.getValue(0)).thenReturn(100);
Mockito.when(tuple.getSourceComponent()).thenReturn("bolt0");
Mockito.when(tuple.getSourceStreamId()).thenReturn("inputstream");
}
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class StreamBuilderTest method testBranch.
@Test
public void testBranch() throws Exception {
Stream<Tuple> stream = streamBuilder.newStream(newSpout(Utils.DEFAULT_STREAM_ID));
Stream<Tuple>[] streams = stream.branch(x -> true);
StormTopology topology = streamBuilder.build();
assertEquals(1, topology.get_spouts_size());
assertEquals(1, topology.get_bolts_size());
Map<GlobalStreamId, Grouping> expected = new HashMap<>();
String spoutId = topology.get_spouts().keySet().iterator().next();
expected.put(new GlobalStreamId(spoutId, "default"), Grouping.shuffle(new NullStruct()));
assertEquals(expected, topology.get_bolts().values().iterator().next().get_common().get_inputs());
assertEquals(1, streams.length);
assertEquals(1, streams[0].node.getOutputStreams().size());
String parentStream = streams[0].node.getOutputStreams().iterator().next() + "-branch";
assertEquals(1, streams[0].node.getParents(parentStream).size());
Node processorNdoe = streams[0].node.getParents(parentStream).iterator().next();
assertTrue(processorNdoe instanceof ProcessorNode);
assertTrue(((ProcessorNode) processorNdoe).getProcessor() instanceof BranchProcessor);
assertTrue(processorNdoe.getParents("default").iterator().next() instanceof SpoutNode);
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class WindowedProcessorBoltTest method setUpMockTuples.
private void setUpMockTuples(Tuple... tuples) {
for (Tuple tuple : tuples) {
Mockito.when(tuple.size()).thenReturn(1);
Mockito.when(tuple.getValue(0)).thenReturn(100);
Mockito.when(tuple.getSourceComponent()).thenReturn("bolt0");
Mockito.when(tuple.getSourceStreamId()).thenReturn("inputstream");
}
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class StatefulWindowedBoltExecutorTest method getMockTuples.
private List<Tuple> getMockTuples(int count) {
List<Tuple> mockTuples = new ArrayList<>();
for (long i = 0; i < count; i++) {
Tuple mockTuple = Mockito.mock(Tuple.class);
Mockito.when(mockTuple.getLongByField("msgid")).thenReturn(i);
Mockito.when(mockTuple.getSourceTask()).thenReturn(1);
Mockito.when(mockTuple.getSourceGlobalStreamId()).thenReturn(new GlobalStreamId("a", "s"));
mockTuples.add(mockTuple);
}
return mockTuples;
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class MockTupleHelpers method mockTuple.
public static Tuple mockTuple(String componentId, String streamId) {
Tuple tuple = Mockito.mock(Tuple.class);
Mockito.when(tuple.getSourceComponent()).thenReturn(componentId);
Mockito.when(tuple.getSourceStreamId()).thenReturn(streamId);
return tuple;
}
Aggregations