Program: 37689
Project: 37689
Buggy source:
/** 
 * Verifies that when we call connect that it makes the appropriate calls to ConsumerStateManager to initialize. This test has the ConsumerStateManager (a mock) return an empty ConsumerState. We verify that our internal kafka client then knows to start reading every partition from the earliest available offset.
 */
@Test public void testConnectWithMultiplePartitionsOnTopicWithNoStateSaved(){
  final String consumerId="String_Node_Str";
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  final SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,consumerId,topicName);
  config.setKafkaConsumerProperty("String_Node_Str","String_Node_Str");
  KafkaConsumer<byte[],byte[]> mockKafkaConsumer=mock(KafkaConsumer.class);
  List<PartitionInfo> mockPartitionInfos=Lists.newArrayList(new PartitionInfo(topicName,0,new Node(0,"String_Node_Str",9092),new Node[0],new Node[0]),new PartitionInfo(topicName,1,new Node(0,"String_Node_Str",9092),new Node[0],new Node[0]),new PartitionInfo(topicName,2,new Node(0,"String_Node_Str",9092),new Node[0],new Node[0]));
  when(mockKafkaConsumer.partitionsFor(eq(topicName))).thenReturn(mockPartitionInfos);
  PersistenceManager mockPersistenceManager=mock(PersistenceManager.class);
  ConsumerState emptyConsumerState=new ConsumerState();
  when(mockPersistenceManager.retrieveConsumerState(eq(consumerId))).thenReturn(emptyConsumerState);
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,mockPersistenceManager,mockKafkaConsumer);
  sidelineConsumer.open(null);
  verify(mockKafkaConsumer,times(1)).assign(eq(Lists.newArrayList(new TopicPartition(topicName,0),new TopicPartition(topicName,1),new TopicPartition(topicName,2))));
  verify(mockKafkaConsumer,times(1)).seekToBeginning(eq(Lists.newArrayList(new TopicPartition(topicName,0),new TopicPartition(topicName,1),new TopicPartition(topicName,2))));
}

Fixed version (ground truth):
/** 
 * Verifies that when we call connect that it makes the appropriate calls to ConsumerStateManager to initialize. This test has the ConsumerStateManager (a mock) return an empty ConsumerState. We verify that our internal kafka client then knows to start reading every partition from the earliest available offset.
 */
@Test public void testConnectWithMultiplePartitionsOnTopicWithNoStateSaved(){
  final String consumerId="String_Node_Str";
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  final SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,consumerId,topicName);
  KafkaConsumer<byte[],byte[]> mockKafkaConsumer=mock(KafkaConsumer.class);
  List<PartitionInfo> mockPartitionInfos=Lists.newArrayList(new PartitionInfo(topicName,0,new Node(0,"String_Node_Str",9092),new Node[0],new Node[0]),new PartitionInfo(topicName,1,new Node(0,"String_Node_Str",9092),new Node[0],new Node[0]),new PartitionInfo(topicName,2,new Node(0,"String_Node_Str",9092),new Node[0],new Node[0]));
  when(mockKafkaConsumer.partitionsFor(eq(topicName))).thenReturn(mockPartitionInfos);
  PersistenceManager mockPersistenceManager=mock(PersistenceManager.class);
  ConsumerState emptyConsumerState=new ConsumerState();
  when(mockPersistenceManager.retrieveConsumerState(eq(consumerId))).thenReturn(emptyConsumerState);
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,mockPersistenceManager,mockKafkaConsumer);
  sidelineConsumer.open(null);
  verify(mockKafkaConsumer,times(1)).assign(eq(Lists.newArrayList(new TopicPartition(topicName,0),new TopicPartition(topicName,1),new TopicPartition(topicName,2))));
  verify(mockKafkaConsumer,times(1)).seekToBeginning(eq(Lists.newArrayList(new TopicPartition(topicName,0),new TopicPartition(topicName,1),new TopicPartition(topicName,2))));
}