nus-yam/ex-repair huggingface dataset:
Program: 61993
Project: 61993
Buggy source:
@Override public void publish(final String channelName,final ContentKey key){
  final MessageListener<String> listener=messageListenerMap.get(channelName);
  if (listener == null) {
    return;
  }
  new Thread(new Runnable(){
    @Override public void run(){
      Message<String> message=new Message<>(channelName,key.keyToString(),System.currentTimeMillis(),null);
      listener.onMessage(message);
    }
  }
).start();
}

Fixed version (ground truth):
@Override public void publish(final String channelName,final ContentKey key){
  final MessageListener<String> listener=messageListenerMap.get(channelName);
  if (listener == null) {
    return;
  }
  threadPoolExecutor.execute(new Runnable(){
    @Override public void run(){
      Message<String> message=new Message<>(channelName,key.keyToString(),System.currentTimeMillis(),null);
      listener.onMessage(message);
    }
  }
);
}
Program: 61994
Project: 61994
Buggy source:
private int getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return 0;
  }
  return (int)(channelConfiguration.getTtlMillis() / 1000);
}

Fixed version (ground truth):
private Optional<Integer> getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return Optional.absent();
  }
  Long ttlMillis=channelConfiguration.getTtlMillis();
  return ttlMillis == null ? Optional.<Integer>absent() : Optional.of((int)(ttlMillis / 1000));
}
Program: 61995
Project: 61995
Buggy source:
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  int ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}

Fixed version (ground truth):
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  Optional<Integer> ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}
Program: 61996
Project: 61996
Buggy source:
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,int ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,ttlSeconds,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}

Fixed version (ground truth):
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,Optional<Integer> ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=createColumn(columnValue,ttlSeconds,columnName);
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}
Program: 61997
Project: 61997
Buggy source:
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  when(inserter.write(channelName,value,0)).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  ChannelConfiguration channelConfig=mock(ChannelConfiguration.class);
  when(channelsCollection.getChannelConfiguration(channelName)).thenReturn(channelConfig);
  when(channelConfig.getTtlMillis()).thenReturn(millis);
  when(inserter.write(channelName,value,Optional.of((int)millis / 1000))).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}
Program: 61999
Project: 61999
Buggy source:
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62000
Project: 62000
Buggy source:
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62001
Project: 62001
Buggy source:
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,0);
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,Optional.of(0));
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}
Program: 62002
Project: 62002
Buggy source:
private int getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return 0;
  }
  return (int)(channelConfiguration.getTtlMillis() / 1000);
}

Fixed version (ground truth):
private Optional<Integer> getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return Optional.absent();
  }
  Long ttlMillis=channelConfiguration.getTtlMillis();
  return ttlMillis == null ? Optional.<Integer>absent() : Optional.of((int)(ttlMillis / 1000));
}
Program: 62003
Project: 62003
Buggy source:
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  int ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}

Fixed version (ground truth):
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  Optional<Integer> ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}
Program: 62004
Project: 62004
Buggy source:
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,int ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,ttlSeconds,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}

Fixed version (ground truth):
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,Optional<Integer> ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=createColumn(columnValue,ttlSeconds,columnName);
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}
Program: 62005
Project: 62005
Buggy source:
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  when(inserter.write(channelName,value,0)).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  ChannelConfiguration channelConfig=mock(ChannelConfiguration.class);
  when(channelsCollection.getChannelConfiguration(channelName)).thenReturn(channelConfig);
  when(channelConfig.getTtlMillis()).thenReturn(millis);
  when(inserter.write(channelName,value,Optional.of((int)millis / 1000))).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}
Program: 62007
Project: 62007
Buggy source:
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62008
Project: 62008
Buggy source:
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62009
Project: 62009
Buggy source:
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,0);
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,Optional.of(0));
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}
Program: 62010
Project: 62010
Buggy source:
private int getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return 0;
  }
  return (int)(channelConfiguration.getTtlMillis() / 1000);
}

Fixed version (ground truth):
private Optional<Integer> getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return Optional.absent();
  }
  Long ttlMillis=channelConfiguration.getTtlMillis();
  return ttlMillis == null ? Optional.<Integer>absent() : Optional.of((int)(ttlMillis / 1000));
}
Program: 62011
Project: 62011
Buggy source:
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  int ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}

Fixed version (ground truth):
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  Optional<Integer> ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}
Program: 62012
Project: 62012
Buggy source:
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,int ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,ttlSeconds,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}

Fixed version (ground truth):
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,Optional<Integer> ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=createColumn(columnValue,ttlSeconds,columnName);
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}
Program: 62013
Project: 62013
Buggy source:
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  when(inserter.write(channelName,value,0)).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  ChannelConfiguration channelConfig=mock(ChannelConfiguration.class);
  when(channelsCollection.getChannelConfiguration(channelName)).thenReturn(channelConfig);
  when(channelConfig.getTtlMillis()).thenReturn(millis);
  when(inserter.write(channelName,value,Optional.of((int)millis / 1000))).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}
Program: 62015
Project: 62015
Buggy source:
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62016
Project: 62016
Buggy source:
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62017
Project: 62017
Buggy source:
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,0);
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,Optional.of(0));
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}
Program: 62018
Project: 62018
Buggy source:
private int getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return 0;
  }
  return (int)(channelConfiguration.getTtlMillis() / 1000);
}

Fixed version (ground truth):
private Optional<Integer> getTtlSeconds(String channelName){
  ChannelConfiguration channelConfiguration=getChannelConfiguration(channelName);
  if (null == channelConfiguration) {
    return Optional.absent();
  }
  Long ttlMillis=channelConfiguration.getTtlMillis();
  return ttlMillis == null ? Optional.<Integer>absent() : Optional.of((int)(ttlMillis / 1000));
}
Program: 62019
Project: 62019
Buggy source:
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  int ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}

Fixed version (ground truth):
@Override public ValueInsertionResult insert(String channelName,Optional<String> contentType,Optional<String> contentLanguage,byte[] data){
  logger.debug("String_Node_Str" + data.length + "String_Node_Str"+ contentType+ "String_Node_Str"+ channelName);
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,contentLanguage,data,timeProvider.getMillis());
  Optional<Integer> ttlSeconds=getTtlSeconds(channelName);
  ValueInsertionResult result=cassandraValueWriter.write(channelName,value,ttlSeconds);
  DataHubKey insertedKey=result.getKey();
  setLastUpdateKey(channelName,insertedKey);
  if (insertedKey.isNewRow()) {
    channelsCollection.updateLatestRowKey(channelName,result.getRowKey());
  }
  return result;
}
Program: 62020
Project: 62020
Buggy source:
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,int ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,ttlSeconds,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}

Fixed version (ground truth):
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue,Optional<Integer> ttlSeconds){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey(channelName);
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=createColumn(columnValue,ttlSeconds,columnName);
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,DATA_HUB_COLUMN_FAMILY_NAME,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key,rowKey,timeProvider.getDate());
}
Program: 62021
Project: 62021
Buggy source:
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  when(inserter.write(channelName,value,0)).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testInsert_lastUpdateCacheMiss() throws Exception {
  DataHubKey key=new DataHubKey((short)1003);
  String channelName="String_Node_Str";
  byte[] data="String_Node_Str".getBytes();
  Optional<String> contentType=Optional.of("String_Node_Str");
  long millis=90210L;
  DataHubCompositeValue value=new DataHubCompositeValue(contentType,Optional.<String>absent(),data,millis);
  ValueInsertionResult expected=new ValueInsertionResult(key,null,null);
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  CassandraValueWriter inserter=mock(CassandraValueWriter.class);
  CassandraValueReader reader=mock(CassandraValueReader.class);
  ConcurrentMap<String,DataHubKey> lastUpdatedMap=mock(ConcurrentMap.class);
  TimeProvider timeProvider=mock(TimeProvider.class);
  ChannelConfiguration channelConfig=mock(ChannelConfiguration.class);
  when(channelsCollection.getChannelConfiguration(channelName)).thenReturn(channelConfig);
  when(channelConfig.getTtlMillis()).thenReturn(millis);
  when(inserter.write(channelName,value,Optional.of((int)millis / 1000))).thenReturn(new ValueInsertionResult(key,null,null));
  when(timeProvider.getMillis()).thenReturn(millis);
  CassandraChannelDao testClass=new CassandraChannelDao(channelsCollection,inserter,reader,lastUpdatedMap,null,null,timeProvider){
    @Override public Optional<DataHubKey> findLastUpdatedKey(    String channelName){
      return Optional.absent();
    }
  }
;
  ValueInsertionResult result=testClass.insert(channelName,contentType,Optional.<String>absent(),data);
  assertEquals(expected,result);
}
Program: 62023
Project: 62023
Buggy source:
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=HInvalidRequestException.class) public void testOtherExceptionMessages() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}
Program: 62024
Project: 62024
Buggy source:
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,0);
}

Fixed version (ground truth):
@Test(expected=NoSuchChannelException.class) public void testInsertWithMissingChannel() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  when(mutator.insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  testClass.write(CHANNEL_NAME,value,Optional.of(0));
}