use of org.apache.storm.task.OutputCollector in project storm by apache.
the class RollingCountBoltTest method shouldEmitSomethingIfAtLeastOneObjectWasCountedAndTickTupleIsReceived.
@SuppressWarnings("rawtypes")
@Test
public void shouldEmitSomethingIfAtLeastOneObjectWasCountedAndTickTupleIsReceived() {
// given
Tuple normalTuple = mockNormalTuple(new Object());
Tuple tickTuple = MockTupleHelpers.mockTickTuple();
RollingCountBolt bolt = new RollingCountBolt();
Map<String, Object> conf = mock(Map.class);
TopologyContext context = mock(TopologyContext.class);
OutputCollector collector = mock(OutputCollector.class);
bolt.prepare(conf, context, collector);
// when
bolt.execute(normalTuple);
bolt.execute(tickTuple);
// then
verify(collector).emit(any(Values.class));
}
use of org.apache.storm.task.OutputCollector in project metron by apache.
the class ErrorUtilsTest method handleErrorShouldEmitAndReportError.
@Test
public void handleErrorShouldEmitAndReportError() {
Throwable e = new Exception("error");
MetronError error = new MetronError().withMessage("error message").withThrowable(e);
OutputCollector collector = mock(OutputCollector.class);
StormErrorUtils.handleError(collector, error);
verify(collector, times(1)).emit(eq(Constants.ERROR_STREAM), argThat(new MetronErrorJSONMatcher(error.getJSONObject())));
verify(collector, times(1)).reportError(any());
}
use of org.apache.storm.task.OutputCollector in project metron by apache.
the class StormParserDriver method run.
public ProcessorResult<List<byte[]>> run(Iterable<byte[]> in) {
ShimParserBolt bolt = new ShimParserBolt(new ArrayList<>());
byte[] b = SerializationUtils.serialize(bolt);
ShimParserBolt b2 = (ShimParserBolt) SerializationUtils.deserialize(b);
OutputCollector collector = mock(OutputCollector.class);
bolt.prepare(null, null, collector);
for (byte[] record : in) {
Tuple tuple = toTuple(record);
bolt.execute(tuple);
verify(collector, times(1)).ack(tuple);
}
return bolt.getResults();
}
Aggregations