Source:
public void testNextTupleEmitsFailedMessagesEvenWhenMaxUncommittedOffsetsIsExceeded() throws IOException { try (SimulatedTime simulatedTime = new SimulatedTime()) { KafkaSpout<String, String> spout = SpoutWithMockedConsumerSetupHelper.setupSpout(spoutConfig, conf, contextMock, collectorMock, consumerMock, partition); Map<TopicPartition, List<ConsumerRecord<String, String>>> records = new HashMap<>(); int numRecords = spoutConfig.getMaxUncommittedOffsets(); records.put(partition, SpoutWithMockedConsumerSetupHelper.<String, String>createRecords(partition, 0, numRecords)); when(consumerMock.poll(anyLong())) .thenReturn(new ConsumerRecords<>(records)); OffsetAndMetadataStub.committed(consumerMock); for (int i = 0; i < numRecords; i++) { spout.nextTuple(); } ArgumentCaptor<KafkaSpoutMessageId> messageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class); verify(collectorMock, times(numRecords)).emit(anyString(), anyList(), messageIds.capture()); for (KafkaSpoutMessageId messageId : messageIds.getAllValues()) { spout.fail(messageId); } reset(collectorMock); Time.advanceTime(50); for (int i = 0; i < numRecords; i++) { spout.nextTuple(); } ArgumentCaptor<KafkaSpoutMessageId> retryMessageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class); verify(collectorMock, times(numRecords)).emit(anyString(), anyList(), retryMessageIds.capture()); List<Long> failedOffsets = new ArrayList<>(); for (KafkaSpoutMessageId msgId : messageIds.getAllValues()) { failedOffsets.add(msgId.offset()); } InOrder inOrder = inOrder(consumerMock); inOrder.verify(consumerMock).seek(partition, failedOffsets.get(0)); inOrder.verify(consumerMock).poll(anyLong()); } }

Target:
public void testNextTupleEmitsFailedMessagesEvenWhenMaxUncommittedOffsetsIsExceeded() throws IOException { try (SimulatedTime simulatedTime = new SimulatedTime()) { KafkaSpout<String, String> spout = SpoutWithMockedConsumerSetupHelper.setupSpout(spoutConfig, conf, contextMock, collectorMock, consumerMock, partition); Map<TopicPartition, List<ConsumerRecord<String, String>>> records = new HashMap<>(); int numRecords = spoutConfig.getMaxUncommittedOffsets(); records.put(partition, SpoutWithMockedConsumerSetupHelper.<String, String>createRecords(partition, 0, numRecords)); when(consumerMock.poll(anyLong())) .thenReturn(new ConsumerRecords<>(records)); for (int i = 0; i < numRecords; i++) { spout.nextTuple(); } ArgumentCaptor<KafkaSpoutMessageId> messageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class); verify(collectorMock, times(numRecords)).emit(anyString(), anyList(), messageIds.capture()); for (KafkaSpoutMessageId messageId : messageIds.getAllValues()) { spout.fail(messageId); } reset(collectorMock); Time.advanceTime(50); for (int i = 0; i < numRecords; i++) { spout.nextTuple(); } ArgumentCaptor<KafkaSpoutMessageId> retryMessageIds = ArgumentCaptor.forClass(KafkaSpoutMessageId.class); verify(collectorMock, times(numRecords)).emit(anyString(), anyList(), retryMessageIds.capture()); List<Long> failedOffsets = new ArrayList<>(); for (KafkaSpoutMessageId msgId : messageIds.getAllValues()) { failedOffsets.add(msgId.offset()); } InOrder inOrder = inOrder(consumerMock); inOrder.verify(consumerMock).seek(partition, failedOffsets.get(0)); inOrder.verify(consumerMock).poll(anyLong()); } }