Program: 37686
Project: 37686
Buggy source:
/** 
 * Tests that our logic for flushing consumer state is disabled if auto commit is disabled. This is kind of a weak test for this.
 */
@Test public void testTimedFlushConsumerStateWhenAutoCommitIsDisabled() throws InterruptedException {
  final String expectedConsumerId="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,expectedConsumerId,topicName);
  config.setConsumerStateAutoCommit(false);
  config.setConsumerStateAutoCommitIntervalMs(1000);
  PersistenceManager mockPersistenceManager=mock(PersistenceManager.class);
  Instant instant=Clock.systemUTC().instant();
  Clock mockClock=Clock.fixed(instant,ZoneId.systemDefault());
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,mockPersistenceManager);
  sidelineConsumer.setClock(mockClock);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  Thread.sleep(1500);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  instant=instant.plus(2000,ChronoUnit.MILLIS);
  mockClock=Clock.fixed(instant,ZoneId.systemDefault());
  sidelineConsumer.setClock(mockClock);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  instant=instant.plus(1500,ChronoUnit.MILLIS);
  mockClock=Clock.fixed(instant,ZoneId.systemDefault());
  sidelineConsumer.setClock(mockClock);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
}

Fixed version (ground truth):
/** 
 * Tests that our logic for flushing consumer state is disabled if auto commit is disabled. This is kind of a weak test for this.
 */
@Test public void testTimedFlushConsumerStateWhenAutoCommitIsDisabled() throws InterruptedException {
  final SidelineConsumerConfig config=getDefaultSidelineConsumerConfig(topicName);
  config.setConsumerStateAutoCommit(false);
  config.setConsumerStateAutoCommitIntervalMs(1000);
  PersistenceManager mockPersistenceManager=mock(PersistenceManager.class);
  Instant instant=Clock.systemUTC().instant();
  Clock mockClock=Clock.fixed(instant,ZoneId.systemDefault());
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,mockPersistenceManager);
  sidelineConsumer.setClock(mockClock);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  Thread.sleep(1500);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  instant=instant.plus(2000,ChronoUnit.MILLIS);
  mockClock=Clock.fixed(instant,ZoneId.systemDefault());
  sidelineConsumer.setClock(mockClock);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
  instant=instant.plus(1500,ChronoUnit.MILLIS);
  mockClock=Clock.fixed(instant,ZoneId.systemDefault());
  sidelineConsumer.setClock(mockClock);
  sidelineConsumer.timedFlushConsumerState();
  verify(mockPersistenceManager,never()).persistConsumerState(anyString(),anyObject());
}