PageViewBolt extends BaseBasicBolt { @Override public void execute(Tuple input, BasicOutputCollector collector) { PageView view = PageView.fromString(input.getString(0)); collector.emit(new Values(view.getValue(field1), view.getValue(field2))); } PageViewBolt(Item field1, Item field2); @Override void execute(Tuple input, BasicOutputCollector collector); @Override void declareOutputFields(OutputFieldsDeclarer declarer); final Item field1; final Item field2; }
@Test(dataProvider = "getAnyFields") public void shouldEmitOnExecute(Item field1, Item field2) { PageViewBolt bolt = new PageViewBolt(field1, field2); BasicOutputCollector collector = mock(BasicOutputCollector.class); Tuple input = MockTupleHelpers.mockAnyTuple(); when(input.getString(0)).thenReturn("http: bolt.execute(input, collector); verify(collector, times(1)).emit(any(Values.class)); }