nus-yam/ex-repair huggingface dataset:
Program: 105145
Project: 105145
Buggy source:
@Override public Answer attachVolume(final AttachCommand cmd){
  final DiskTO disk=cmd.getDisk();
  final VolumeObjectTO vol=(VolumeObjectTO)disk.getData();
  final PrimaryDataStoreTO primaryStore=(PrimaryDataStoreTO)vol.getDataStore();
  final String vmName=cmd.getVmName();
  final String serial=resource.diskUuidToSerial(vol.getUuid());
  try {
    final Connect conn=LibvirtConnection.getConnectionByVmName(vmName);
    storagePoolMgr.connectPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),vol.getPath(),disk.getDetails());
    final KVMPhysicalDisk phyDisk=storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),vol.getPath());
    attachOrDetachDisk(conn,true,vmName,phyDisk,disk.getDiskSeq().intValue(),serial);
    return new AttachAnswer(disk);
  }
 catch (  final LibvirtException e) {
    s_logger.debug("String_Node_Str" + vol.getPath() + "String_Node_Str",e);
    storagePoolMgr.disconnectPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),vol.getPath());
    return new AttachAnswer(e.toString());
  }
catch (  final InternalErrorException e) {
    s_logger.debug("String_Node_Str" + vol.getPath() + "String_Node_Str",e);
    return new AttachAnswer(e.toString());
  }
}

Fixed version (ground truth):
@Override public Answer attachVolume(final AttachCommand cmd){
  final DiskTO disk=cmd.getDisk();
  final VolumeObjectTO vol=(VolumeObjectTO)disk.getData();
  final PrimaryDataStoreTO primaryStore=(PrimaryDataStoreTO)vol.getDataStore();
  final String vmName=cmd.getVmName();
  final String serial=resource.diskUuidToSerial(vol.getUuid());
  try {
    final Connect conn=LibvirtConnection.getConnectionByVmName(vmName);
    storagePoolMgr.connectPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),vol.getPath(),disk.getDetails());
    final KVMPhysicalDisk phyDisk=storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),vol.getPath());
    attachOrDetachDisk(conn,true,vmName,phyDisk,disk.getDiskSeq().intValue(),serial,vol.getBytesReadRate(),vol.getBytesWriteRate(),vol.getIopsReadRate(),vol.getIopsWriteRate());
    return new AttachAnswer(disk);
  }
 catch (  final LibvirtException e) {
    s_logger.debug("String_Node_Str" + vol.getPath() + "String_Node_Str",e);
    storagePoolMgr.disconnectPhysicalDisk(primaryStore.getPoolType(),primaryStore.getUuid(),vol.getPath());
    return new AttachAnswer(e.toString());
  }
catch (  final InternalErrorException e) {
    s_logger.debug("String_Node_Str" + vol.getPath() + "String_Node_Str",e);
    return new AttachAnswer(e.toString());
  }
}
Program: 105146
Project: 105146
Buggy source:
@Override public Long getDiskBytesWriteRate(ServiceOfferingVO offering,DiskOfferingVO diskOffering){
  if ((offering != null) && (offering.getBytesWriteRate() != null) && (offering.getBytesWriteRate() > 0)) {
    return offering.getBytesWriteRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getBytesWriteRate() != null) && (diskOffering.getBytesWriteRate() > 0)) {
    return diskOffering.getBytesWriteRate();
  }
 else {
    Long bytesWriteRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesWriteRate.key()));
    if ((bytesWriteRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return bytesWriteRate;
    }
  }
  return 0L;
}

Fixed version (ground truth):
@Override public Long getDiskBytesWriteRate(final ServiceOffering offering,final DiskOffering diskOffering){
  if ((offering != null) && (offering.getBytesWriteRate() != null) && (offering.getBytesWriteRate() > 0)) {
    return offering.getBytesWriteRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getBytesWriteRate() != null) && (diskOffering.getBytesWriteRate() > 0)) {
    return diskOffering.getBytesWriteRate();
  }
 else {
    Long bytesWriteRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesWriteRate.key()));
    if ((bytesWriteRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return bytesWriteRate;
    }
  }
  return 0L;
}
Program: 105147
Project: 105147
Buggy source:
@Override public Long getDiskIopsReadRate(ServiceOfferingVO offering,DiskOfferingVO diskOffering){
  if ((offering != null) && (offering.getIopsReadRate() != null) && (offering.getIopsReadRate() > 0)) {
    return offering.getIopsReadRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getIopsReadRate() != null) && (diskOffering.getIopsReadRate() > 0)) {
    return diskOffering.getIopsReadRate();
  }
 else {
    Long iopsReadRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsReadRate.key()));
    if ((iopsReadRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return iopsReadRate;
    }
  }
  return 0L;
}

Fixed version (ground truth):
@Override public Long getDiskIopsReadRate(final ServiceOffering offering,final DiskOffering diskOffering){
  if ((offering != null) && (offering.getIopsReadRate() != null) && (offering.getIopsReadRate() > 0)) {
    return offering.getIopsReadRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getIopsReadRate() != null) && (diskOffering.getIopsReadRate() > 0)) {
    return diskOffering.getIopsReadRate();
  }
 else {
    Long iopsReadRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsReadRate.key()));
    if ((iopsReadRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return iopsReadRate;
    }
  }
  return 0L;
}
Program: 105148
Project: 105148
Buggy source:
@Override public Long getDiskBytesReadRate(ServiceOfferingVO offering,DiskOfferingVO diskOffering){
  if ((offering != null) && (offering.getBytesReadRate() != null) && (offering.getBytesReadRate() > 0)) {
    return offering.getBytesReadRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getBytesReadRate() != null) && (diskOffering.getBytesReadRate() > 0)) {
    return diskOffering.getBytesReadRate();
  }
 else {
    Long bytesReadRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesReadRate.key()));
    if ((bytesReadRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return bytesReadRate;
    }
  }
  return 0L;
}

Fixed version (ground truth):
@Override public Long getDiskBytesReadRate(final ServiceOffering offering,final DiskOffering diskOffering){
  if ((offering != null) && (offering.getBytesReadRate() != null) && (offering.getBytesReadRate() > 0)) {
    return offering.getBytesReadRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getBytesReadRate() != null) && (diskOffering.getBytesReadRate() > 0)) {
    return diskOffering.getBytesReadRate();
  }
 else {
    Long bytesReadRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesReadRate.key()));
    if ((bytesReadRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return bytesReadRate;
    }
  }
  return 0L;
}
Program: 105149
Project: 105149
Buggy source:
@Override public Long getDiskIopsWriteRate(ServiceOfferingVO offering,DiskOfferingVO diskOffering){
  if ((offering != null) && (offering.getIopsWriteRate() != null) && (offering.getIopsWriteRate() > 0)) {
    return offering.getIopsWriteRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getIopsWriteRate() != null) && (diskOffering.getIopsWriteRate() > 0)) {
    return diskOffering.getIopsWriteRate();
  }
 else {
    Long iopsWriteRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsWriteRate.key()));
    if ((iopsWriteRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return iopsWriteRate;
    }
  }
  return 0L;
}

Fixed version (ground truth):
@Override public Long getDiskIopsWriteRate(final ServiceOffering offering,final DiskOffering diskOffering){
  if ((offering != null) && (offering.getIopsWriteRate() != null) && (offering.getIopsWriteRate() > 0)) {
    return offering.getIopsWriteRate();
  }
 else   if ((diskOffering != null) && (diskOffering.getIopsWriteRate() != null) && (diskOffering.getIopsWriteRate() > 0)) {
    return diskOffering.getIopsWriteRate();
  }
 else {
    Long iopsWriteRate=Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsWriteRate.key()));
    if ((iopsWriteRate > 0) && ((offering == null) || (!offering.getSystemUse()))) {
      return iopsWriteRate;
    }
  }
  return 0L;
}
Program: 105153
Project: 105153
Buggy source:
/** 
 * This test verifies that CPU topology is properly set for hex-core
 */
@Test public void testCreateVMFromSpecWithTopology6(){
  final int id=_random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=12;
  final int minSpeed=1024;
  final int maxSpeed=2048;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,minSpeed,maxSpeed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(_hyperVisorType);
  verifyVm(to,vm);
}

Fixed version (ground truth):
/** 
 * This test verifies that CPU topology is properly set for hex-core
 */
@Test public void testCreateVMFromSpecWithTopology6(){
  final int id=random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=12;
  final int minSpeed=1024;
  final int maxSpeed=2048;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,minSpeed,maxSpeed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(hyperVisorType);
  verifyVm(to,vm);
}
Program: 105154
Project: 105154
Buggy source:
/** 
 * This test verifies that CPU topology is properly set for quad-core
 */
@Test public void testCreateVMFromSpecWithTopology4(){
  final int id=_random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=8;
  final int minSpeed=1024;
  final int maxSpeed=2048;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,minSpeed,maxSpeed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(_hyperVisorType);
  verifyVm(to,vm);
}

Fixed version (ground truth):
/** 
 * This test verifies that CPU topology is properly set for quad-core
 */
@Test public void testCreateVMFromSpecWithTopology4(){
  final int id=random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=8;
  final int minSpeed=1024;
  final int maxSpeed=2048;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,minSpeed,maxSpeed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(hyperVisorType);
  verifyVm(to,vm);
}
Program: 105156
Project: 105156
Buggy source:
/** 
 * This test tests if the Agent can handle a vmSpec coming from a >4.1 management server. It tests if the Agent can handle a vmSpec with overcommit data like minSpeed and maxSpeed in there
 */
@Test public void testCreateVMFromSpec(){
  final int id=_random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=_random.nextInt(2) + 1;
  final int minSpeed=1024;
  final int maxSpeed=2048;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,minSpeed,maxSpeed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(_hyperVisorType);
  verifyVm(to,vm);
}

Fixed version (ground truth):
/** 
 * This test tests if the Agent can handle a vmSpec coming from a >4.1 management server. It tests if the Agent can handle a vmSpec with overcommit data like minSpeed and maxSpeed in there
 */
@Test public void testCreateVMFromSpec(){
  final int id=random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=random.nextInt(2) + 1;
  final int minSpeed=1024;
  final int maxSpeed=2048;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,minSpeed,maxSpeed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(hyperVisorType);
  verifyVm(to,vm);
}
Program: 105157
Project: 105157
Buggy source:
@Test public void testGetHostStatsCommand(){
  Mockito.mock(LibvirtUtilitiesHelper.class);
  final CPUStat cpuStat=Mockito.mock(CPUStat.class);
  final MemStat memStat=Mockito.mock(MemStat.class);
  final String uuid="String_Node_Str";
  final GetHostStatsCommand command=new GetHostStatsCommand(uuid,"String_Node_Str",1l);
  when(libvirtComputingResource.getCPUStat()).thenReturn(cpuStat);
  when(libvirtComputingResource.getMemStat()).thenReturn(memStat);
  when(libvirtComputingResource.getNicStats(Mockito.anyString())).thenReturn(new Pair<Double,Double>(1.0d,1.0d));
  when(cpuStat.getCpuUsedPercent()).thenReturn(0.5d);
  when(memStat.getAvailable()).thenReturn(1500.5d);
  when(memStat.getTotal()).thenReturn(15000d);
  final LibvirtRequestWrapper wrapper=LibvirtRequestWrapper.getInstance();
  assertNotNull(wrapper);
  final Answer answer=wrapper.execute(command,libvirtComputingResource);
  assertTrue(answer.getResult());
  verify(libvirtComputingResource,times(1)).getCPUStat();
  verify(libvirtComputingResource,times(1)).getMemStat();
  verify(cpuStat,times(1)).getCpuUsedPercent();
  verify(memStat,times(1)).getAvailable();
  verify(memStat,times(1)).getTotal();
}

Fixed version (ground truth):
@Test public void testGetHostStatsCommand(){
  final CPUStat cpuStat=Mockito.mock(CPUStat.class);
  final MemStat memStat=Mockito.mock(MemStat.class);
  final String uuid="String_Node_Str";
  final GetHostStatsCommand command=new GetHostStatsCommand(uuid,"String_Node_Str",1l);
  when(libvirtComputingResource.getCPUStat()).thenReturn(cpuStat);
  when(libvirtComputingResource.getMemStat()).thenReturn(memStat);
  when(libvirtComputingResource.getNicStats(Mockito.anyString())).thenReturn(new Pair<Double,Double>(1.0d,1.0d));
  when(cpuStat.getCpuUsedPercent()).thenReturn(0.5d);
  when(memStat.getAvailable()).thenReturn(1500.5d);
  when(memStat.getTotal()).thenReturn(15000d);
  final LibvirtRequestWrapper wrapper=LibvirtRequestWrapper.getInstance();
  assertNotNull(wrapper);
  final Answer answer=wrapper.execute(command,libvirtComputingResource);
  assertTrue(answer.getResult());
  verify(libvirtComputingResource,times(1)).getCPUStat();
  verify(libvirtComputingResource,times(1)).getMemStat();
  verify(cpuStat,times(1)).getCpuUsedPercent();
  verify(memStat,times(1)).getAvailable();
  verify(memStat,times(1)).getTotal();
}
Program: 105158
Project: 105158
Buggy source:
/** 
 * This test tests if the Agent can handle a vmSpec coming from a <=4.1 management server. The overcommit feature has not been merged in there and thus only 'speed' is set.
 */
@Test public void testCreateVMFromSpecLegacy(){
  final int id=_random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=_random.nextInt(2) + 1;
  final int speed=1024;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,speed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(_hyperVisorType);
  verifyVm(to,vm);
}

Fixed version (ground truth):
/** 
 * This test tests if the Agent can handle a vmSpec coming from a <=4.1 management server. The overcommit feature has not been merged in there and thus only 'speed' is set.
 */
@Test public void testCreateVMFromSpecLegacy(){
  final int id=random.nextInt(65534);
  final String name="String_Node_Str";
  final int cpus=random.nextInt(2) + 1;
  final int speed=1024;
  final int minRam=256 * 1024;
  final int maxRam=512 * 1024;
  final String os="String_Node_Str";
  final String vncAddr="String_Node_Str";
  final String vncPassword="String_Node_Str";
  final LibvirtComputingResource lcr=new LibvirtComputingResource();
  final VirtualMachineTO to=new VirtualMachineTO(id,name,VirtualMachine.Type.User,cpus,speed,minRam,maxRam,BootloaderType.HVM,os,false,false,vncPassword);
  to.setVncAddr(vncAddr);
  to.setUuid("String_Node_Str");
  final LibvirtVMDef vm=lcr.createVMFromSpec(to);
  vm.setHvsType(hyperVisorType);
  verifyVm(to,vm);
}
Program: 105159
Project: 105159
Buggy source:
@SuppressWarnings("String_Node_Str") @Test public void testGetVmDiskStatsCommandException(){
  Mockito.mock(Connect.class);
  final LibvirtUtilitiesHelper libvirtUtilitiesHelper=Mockito.mock(LibvirtUtilitiesHelper.class);
  final String vmName="String_Node_Str";
  final String uuid="String_Node_Str";
  final List<String> vms=new ArrayList<String>();
  vms.add(vmName);
  final GetVmDiskStatsCommand command=new GetVmDiskStatsCommand(vms,uuid,"String_Node_Str");
  when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
  try {
    when(libvirtUtilitiesHelper.getConnection()).thenThrow(LibvirtException.class);
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
  final LibvirtRequestWrapper wrapper=LibvirtRequestWrapper.getInstance();
  assertNotNull(wrapper);
  final Answer answer=wrapper.execute(command,libvirtComputingResource);
  assertTrue(answer.getResult());
  verify(libvirtComputingResource,times(1)).getLibvirtUtilitiesHelper();
  try {
    verify(libvirtUtilitiesHelper,times(1)).getConnection();
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
}

Fixed version (ground truth):
@Test @SuppressWarnings("String_Node_Str") public void testGetVmDiskStatsCommandException(){
  final LibvirtUtilitiesHelper libvirtUtilitiesHelper=Mockito.mock(LibvirtUtilitiesHelper.class);
  final String vmName="String_Node_Str";
  final String uuid="String_Node_Str";
  final List<String> vms=new ArrayList<String>();
  vms.add(vmName);
  final GetVmDiskStatsCommand command=new GetVmDiskStatsCommand(vms,uuid,"String_Node_Str");
  when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
  try {
    when(libvirtUtilitiesHelper.getConnection()).thenThrow(LibvirtException.class);
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
  final LibvirtRequestWrapper wrapper=LibvirtRequestWrapper.getInstance();
  assertNotNull(wrapper);
  final Answer answer=wrapper.execute(command,libvirtComputingResource);
  assertTrue(answer.getResult());
  verify(libvirtComputingResource,times(1)).getLibvirtUtilitiesHelper();
  try {
    verify(libvirtUtilitiesHelper,times(1)).getConnection();
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
}
Program: 105162
Project: 105162
Buggy source:
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  super.configure(name,params);
  Map<String,String> configs=_configDao.getConfiguration(params);
  if (params != null) {
    mergeConfigs(configs,params);
  }
  String period_str=configs.get(QuotaConfig.QuotaStatementPeriod.key());
  int period=period_str == null ? 1 : Integer.parseInt(period_str);
  STATEMENT_PERIODS _period=STATEMENT_PERIODS.values()[period];
  return true;
}

Fixed version (ground truth):
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  super.configure(name,params);
  Map<String,String> configs=_configDao.getConfiguration(params);
  if (params != null) {
    mergeConfigs(configs,params);
  }
  String period_str=configs.get(QuotaConfig.QuotaStatementPeriod.key());
  int period=period_str == null ? 1 : Integer.parseInt(period_str);
  QuotaStatementPeriods _period=QuotaStatementPeriods.values()[period];
  return true;
}
Program: 105163
Project: 105163
Buggy source:
@Test public void testSendStatement() throws UnsupportedEncodingException, MessagingException {
  Calendar date=Calendar.getInstance();
  AccountVO accountVO=new AccountVO();
  accountVO.setId(2L);
  accountVO.setDomainId(1L);
  Mockito.when(accountDao.findById(Mockito.anyLong())).thenReturn(accountVO);
  QuotaAccountVO acc=new QuotaAccountVO(2L);
  acc.setQuotaBalance(new BigDecimal(404));
  acc.setLastStatementDate(null);
  List<QuotaAccountVO> accounts=new ArrayList<>();
  accounts.add(acc);
  Mockito.when(quotaAcc.listAllQuotaAccount()).thenReturn(accounts);
  Mockito.when(quotaUsage.findTotalQuotaUsage(Mockito.anyLong(),Mockito.anyLong(),Mockito.anyInt(),Mockito.any(Date.class),Mockito.any(Date.class))).thenReturn(new BigDecimal(100));
  quotaStatement.sendStatement();
  Calendar period[]=quotaStatement.statementTime(date,STATEMENT_PERIODS.MONTHLY);
  if (period != null) {
    Mockito.verify(alertManager,Mockito.times(1)).sendQuotaAlert(Mockito.any(QuotaAlertManagerImpl.DeferredQuotaEmail.class));
  }
}

Fixed version (ground truth):
@Test public void testSendStatement() throws UnsupportedEncodingException, MessagingException {
  Calendar date=Calendar.getInstance();
  AccountVO accountVO=new AccountVO();
  accountVO.setId(2L);
  accountVO.setDomainId(1L);
  Mockito.when(accountDao.findById(Mockito.anyLong())).thenReturn(accountVO);
  QuotaAccountVO acc=new QuotaAccountVO(2L);
  acc.setQuotaBalance(new BigDecimal(404));
  acc.setLastStatementDate(null);
  List<QuotaAccountVO> accounts=new ArrayList<>();
  accounts.add(acc);
  Mockito.when(quotaAcc.listAllQuotaAccount()).thenReturn(accounts);
  Mockito.when(quotaUsage.findTotalQuotaUsage(Mockito.anyLong(),Mockito.anyLong(),Mockito.anyInt(),Mockito.any(Date.class),Mockito.any(Date.class))).thenReturn(new BigDecimal(100));
  quotaStatement.sendStatement();
  Calendar period[]=quotaStatement.statementTime(date,QuotaStatementPeriods.MONTHLY);
  if (period != null) {
    Mockito.verify(alertManager,Mockito.times(1)).sendQuotaAlert(Mockito.any(QuotaAlertManagerImpl.DeferredQuotaEmail.class));
  }
}
Program: 105164
Project: 105164
Buggy source:
@Test public void testStatementPeriodMONTHLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1);
  Calendar period[]=quotaStatement.statementTime(date,STATEMENT_PERIODS.MONTHLY);
  assertTrue(period == null);
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS - 1);
  period=quotaStatement.statementTime(date,STATEMENT_PERIODS.MONTHLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue(period[0].toString(),period[0].before(period[1]));
  assertTrue(period[0].toString(),period[0].get(Calendar.DATE) == 1);
  aCalendar=Calendar.getInstance();
  aCalendar.add(Calendar.MONTH,-1);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue(period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
}

Fixed version (ground truth):
@Test public void testStatementPeriodMONTHLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1);
  Calendar period[]=quotaStatement.statementTime(date,QuotaStatementPeriods.MONTHLY);
  assertTrue(period == null);
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS - 1);
  period=quotaStatement.statementTime(date,QuotaStatementPeriods.MONTHLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue(period[0].toString(),period[0].before(period[1]));
  assertTrue(period[0].toString(),period[0].get(Calendar.DATE) == 1);
  aCalendar=Calendar.getInstance();
  aCalendar.add(Calendar.MONTH,-1);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue(period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
}
Program: 105165
Project: 105165
Buggy source:
@Test public void testStatementPeriodBIMONTHLY(){
  Calendar date=Calendar.getInstance();
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1);
  Calendar period[]=quotaStatement.statementTime(date,STATEMENT_PERIODS.BIMONTHLY);
  assertTrue(period == null);
  date.set(Calendar.DATE,1);
  period=quotaStatement.statementTime(date,STATEMENT_PERIODS.BIMONTHLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue(period[0].toString(),period[0].before(period[1]));
  assertTrue(period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue(period[1].toString(),period[1].get(Calendar.DATE) == 15);
  date=Calendar.getInstance();
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16);
  period=quotaStatement.statementTime(date,STATEMENT_PERIODS.BIMONTHLY);
  assertTrue(period == null);
  date.set(Calendar.DATE,17);
  period=quotaStatement.statementTime(date,STATEMENT_PERIODS.BIMONTHLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue(period[0].toString(),period[0].before(period[1]));
  assertTrue(period[0].toString(),period[0].get(Calendar.DATE) == 16);
  Calendar aCalendar=Calendar.getInstance();
  aCalendar.add(Calendar.MONTH,-1);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue(period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
}

Fixed version (ground truth):
@Test public void testStatementPeriodBIMONTHLY(){
  Calendar date=Calendar.getInstance();
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 1);
  Calendar period[]=quotaStatement.statementTime(date,QuotaStatementPeriods.BIMONTHLY);
  assertTrue(period == null);
  date.set(Calendar.DATE,1);
  period=quotaStatement.statementTime(date,QuotaStatementPeriods.BIMONTHLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue(period[0].toString(),period[0].before(period[1]));
  assertTrue(period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue(period[1].toString(),period[1].get(Calendar.DATE) == 15);
  date=Calendar.getInstance();
  date.set(Calendar.DATE,QuotaStatementImpl.s_LAST_STATEMENT_SENT_DAYS + 16);
  period=quotaStatement.statementTime(date,QuotaStatementPeriods.BIMONTHLY);
  assertTrue(period == null);
  date.set(Calendar.DATE,17);
  period=quotaStatement.statementTime(date,QuotaStatementPeriods.BIMONTHLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue(period[0].toString(),period[0].before(period[1]));
  assertTrue(period[0].toString(),period[0].get(Calendar.DATE) == 16);
  Calendar aCalendar=Calendar.getInstance();
  aCalendar.add(Calendar.MONTH,-1);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue(period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
}
Program: 105166
Project: 105166
Buggy source:
@Test public void testStatementPeriodQUATERLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.MONTH,Calendar.JANUARY);
  date.set(Calendar.DATE,1);
  Calendar period[]=quotaStatement.statementTime(date,STATEMENT_PERIODS.QUATERLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].before(period[1]));
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.MONTH) == Calendar.OCTOBER);
  aCalendar=Calendar.getInstance();
  aCalendar.set(Calendar.MONTH,Calendar.DECEMBER);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
}

Fixed version (ground truth):
@Test public void testStatementPeriodQUATERLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.MONTH,Calendar.JANUARY);
  date.set(Calendar.DATE,1);
  Calendar period[]=quotaStatement.statementTime(date,QuotaStatementPeriods.QUATERLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].before(period[1]));
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.MONTH) == Calendar.OCTOBER);
  aCalendar=Calendar.getInstance();
  aCalendar.set(Calendar.MONTH,Calendar.DECEMBER);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
}
Program: 105167
Project: 105167
Buggy source:
@Test public void testStatementPeriodYEARLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.MONTH,Calendar.JANUARY);
  date.set(Calendar.DATE,1);
  Calendar period[]=quotaStatement.statementTime(date,STATEMENT_PERIODS.YEARLY);
  assertTrue("String_Node_Str",period != null);
  assertTrue(period.length == 2);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].before(period[1]));
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.MONTH) == Calendar.JANUARY);
  aCalendar=Calendar.getInstance();
  aCalendar.set(Calendar.MONTH,Calendar.DECEMBER);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
}

Fixed version (ground truth):
@Test public void testStatementPeriodYEARLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.MONTH,Calendar.JANUARY);
  date.set(Calendar.DATE,1);
  Calendar period[]=quotaStatement.statementTime(date,QuotaStatementPeriods.YEARLY);
  assertTrue("String_Node_Str",period != null);
  assertTrue(period.length == 2);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].before(period[1]));
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.MONTH) == Calendar.JANUARY);
  aCalendar=Calendar.getInstance();
  aCalendar.set(Calendar.MONTH,Calendar.DECEMBER);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
}
Program: 105168
Project: 105168
Buggy source:
@Test public void testStatementPeriodHALFYEARLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.MONTH,Calendar.JANUARY);
  date.set(Calendar.DATE,1);
  Calendar period[]=quotaStatement.statementTime(date,STATEMENT_PERIODS.HALFYEARLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].before(period[1]));
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.MONTH) == Calendar.JULY);
  aCalendar=Calendar.getInstance();
  aCalendar.set(Calendar.MONTH,Calendar.DECEMBER);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
}

Fixed version (ground truth):
@Test public void testStatementPeriodHALFYEARLY(){
  Calendar date=Calendar.getInstance();
  Calendar aCalendar=Calendar.getInstance();
  date=Calendar.getInstance();
  date.set(Calendar.MONTH,Calendar.JANUARY);
  date.set(Calendar.DATE,1);
  Calendar period[]=quotaStatement.statementTime(date,QuotaStatementPeriods.HALFYEARLY);
  assertTrue(period != null);
  assertTrue(period.length == 2);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].before(period[1]));
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.DATE) == 1);
  assertTrue("String_Node_Str" + period[0].toString(),period[0].get(Calendar.MONTH) == Calendar.JULY);
  aCalendar=Calendar.getInstance();
  aCalendar.set(Calendar.MONTH,Calendar.DECEMBER);
  aCalendar.set(Calendar.DATE,aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH) + 1);
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.DATE) == aCalendar.get(Calendar.DATE));
  assertTrue("String_Node_Str" + period[1].toString(),period[1].get(Calendar.MONTH) == aCalendar.get(Calendar.MONTH));
}
Program: 105169
Project: 105169
Buggy source:
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  _executor=Executors.newScheduledThreadPool(1,new NamedThreadFactory("String_Node_Str"));
  _monitoringInterval=UploadMonitoringInterval.value();
  _uploadOperationTimeout=UploadOperationTimeout.value() * 60 * 1000;
  _nodeId=ManagementServerNode.getManagementServerId();
  return true;
}

Fixed version (ground truth):
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  _executor=Executors.newScheduledThreadPool(1,new NamedThreadFactory("String_Node_Str"));
  _monitoringInterval=UploadMonitoringInterval.value();
  _uploadOperationTimeout=UploadOperationTimeout.value() * 60 * 1000L;
  _nodeId=ManagementServerNode.getManagementServerId();
  return true;
}
Program: 105170
Project: 105170
Buggy source:
@Override public String[] applyVpnUsers(final Network network,final List<? extends VpnUser> users,final List<DomainRouterVO> routers) throws ResourceUnavailableException {
  if (routers == null || routers.isEmpty()) {
    s_logger.warn("String_Node_Str");
    throw new ResourceUnavailableException("String_Node_Str" + network.getId(),DataCenter.class,network.getDataCenterId());
  }
  s_logger.debug("String_Node_Str");
  final BasicVpnRules vpnRules=new BasicVpnRules(network,users);
  boolean agentResults=true;
  for (  final DomainRouterVO router : routers) {
    if (router.getState() != State.Running) {
      s_logger.warn("String_Node_Str");
      throw new ResourceUnavailableException("String_Node_Str" + router.getState(),DataCenter.class,network.getDataCenterId());
    }
    final boolean agentResult=vpnRules.accept(_basicVisitor,router);
    agentResults=agentResults && agentResult;
  }
  final String[] result=new String[users.size()];
  for (int i=0; i < result.length; i++) {
    if (agentResults) {
      result[i]=null;
    }
 else {
      result[i]=String.valueOf(agentResults);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public String[] applyVpnUsers(final Network network,final List<? extends VpnUser> users,final List<DomainRouterVO> routers) throws ResourceUnavailableException {
  if (routers == null || routers.isEmpty()) {
    s_logger.warn("String_Node_Str");
    throw new ResourceUnavailableException("String_Node_Str" + network.getId(),DataCenter.class,network.getDataCenterId());
  }
  s_logger.debug("String_Node_Str");
  final BasicVpnRules vpnRules=new BasicVpnRules(network,users);
  boolean agentResults=true;
  for (  final DomainRouterVO router : routers) {
    if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
      s_logger.info("String_Node_Str" + router.getInstanceName() + "String_Node_Str"+ router.getState()+ "String_Node_Str");
      continue;
    }
 else     if (router.getState() != State.Running) {
      s_logger.warn("String_Node_Str");
      throw new ResourceUnavailableException("String_Node_Str" + router.getState(),DataCenter.class,network.getDataCenterId());
    }
    final boolean agentResult=vpnRules.accept(_basicVisitor,router);
    agentResults=agentResults && agentResult;
  }
  final String[] result=new String[users.size()];
  for (int i=0; i < result.length; i++) {
    if (agentResults) {
      result[i]=null;
    }
 else {
      result[i]=String.valueOf(agentResults);
    }
  }
  return result;
}
Program: 105171
Project: 105171
Buggy source:
public Map<String,String> getDetails(){
  return details;
}

Fixed version (ground truth):
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      String key : value.keySet()) {
        customparameterMap.put(key,value.get(key));
      }
    }
  }
  return customparameterMap;
}
Program: 105172
Project: 105172
Buggy source:
public Map<String,String> getDetails(){
  return details;
}

Fixed version (ground truth):
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      String key : value.keySet()) {
        customparameterMap.put(key,value.get(key));
      }
    }
  }
  return customparameterMap;
}
Program: 105173
Project: 105173
Buggy source:
/** 
 * 1 millisecond = 1e+6 nanoseconds 1 second = 1000 milliseconds = 1e+9 nanoseconds
 * @return the duration in nanoseconds.
 */
public long getDuration(){
  if (startTickNanoSeconds != null && stopTickNanoSeconds != null) {
    final long timeInNanoSeconds=stopTickNanoSeconds - startTickNanoSeconds;
    return timeInNanoSeconds;
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * 1 millisecond = 1e+6 nanoseconds 1 second = 1000 milliseconds = 1e+9 nanoseconds
 * @return the duration in nanoseconds.
 */
public long getDuration(){
  if (startTickNanoSeconds != null && stopTickNanoSeconds != null) {
    return stopTickNanoSeconds - startTickNanoSeconds;
  }
  return -1;
}
Program: 105174
Project: 105174
Buggy source:
/** 
 * 1 millisecond = 1e+6 nanoseconds 1 second = 1000 millisecond = 1e+9 nanoseconds
 * @return the duration in milliseconds.
 */
public long getDurationInMillis(){
  if (startTickNanoSeconds != null && stopTickNanoSeconds != null) {
    final long timeInMillis=(stopTickNanoSeconds - startTickNanoSeconds) / (long)Math.pow(MILLIS_FACTOR,EXPONENT);
    return timeInMillis;
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * 1 millisecond = 1e+6 nanoseconds 1 second = 1000 millisecond = 1e+9 nanoseconds
 * @return the duration in milliseconds.
 */
public long getDurationInMillis(){
  if (startTickNanoSeconds != null && stopTickNanoSeconds != null) {
    return (stopTickNanoSeconds - startTickNanoSeconds) / (long)Math.pow(MILLIS_FACTOR,EXPONENT);
  }
  return -1;
}
Program: 105175
Project: 105175
Buggy source:
@Test public void testProfilerInMillis(){
  s_logger.info("String_Node_Str");
  final Profiler pf=new Profiler();
  pf.start();
  try {
    Thread.sleep(ONE_SECOND);
  }
 catch (  final InterruptedException e) {
  }
  pf.stop();
  final long durationInMillis=pf.getDurationInMillis();
  s_logger.info("String_Node_Str" + durationInMillis);
  Assert.assertTrue(durationInMillis >= MILLIS_FACTOR && durationInMillis <= MILLIS_FACTOR + MARGIN);
  s_logger.info("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testProfilerInMillis(){
  final long sleepTimeMillis=SLEEP_TIME_NANO / 1000000L;
  pf.start();
  pf.stop();
  Assert.assertTrue(pf.getDurationInMillis() == sleepTimeMillis);
}
Program: 105176
Project: 105176
Buggy source:
@Test public void testProfilerNoStop(){
  final Profiler pf=new Profiler();
  pf.start();
  try {
    Thread.sleep(20);
  }
 catch (  final InterruptedException e) {
  }
  Assert.assertTrue(pf.getDurationInMillis() == -1);
  Assert.assertFalse(pf.isStopped());
}

Fixed version (ground truth):
@Test public void testProfilerNoStop(){
  final long expectedAnswer=-1;
  pf.start();
  Assert.assertTrue(pf.getDurationInMillis() == expectedAnswer);
  Assert.assertFalse(pf.isStopped());
}
Program: 105177
Project: 105177
Buggy source:
@Test public void testProfilerInNano(){
  final Profiler pf=new Profiler();
  pf.start();
  try {
    Thread.sleep(ONE_SECOND);
  }
 catch (  final InterruptedException e) {
  }
  pf.stop();
  final long duration=pf.getDuration();
  s_logger.info("String_Node_Str" + duration);
  Assert.assertTrue(duration >= Math.pow(MILLIS_FACTOR,EXPONENT));
}

Fixed version (ground truth):
@Test public void testProfilerInNano(){
  final long sleepTimeNano=SLEEP_TIME_NANO;
  pf.start();
  pf.stop();
  Assert.assertTrue(pf.getDuration() == sleepTimeNano);
}
Program: 105178
Project: 105178
Buggy source:
@Test public void testProfilerNoStart(){
  final Profiler pf=new Profiler();
  try {
    Thread.sleep(20);
  }
 catch (  final InterruptedException e) {
  }
  pf.stop();
  Assert.assertTrue(pf.getDurationInMillis() == -1);
  Assert.assertFalse(pf.isStarted());
}

Fixed version (ground truth):
@Test public void testProfilerNoStart(){
  final long expectedAnswer=-1;
  pf.stop();
  Assert.assertTrue(pf.getDurationInMillis() == expectedAnswer);
  Assert.assertFalse(pf.isStarted());
}
Program: 105179
Project: 105179
Buggy source:
/** 
 * Mount remote device named on local file system on subfolder of _parent field. <p> Supported schemes are "nfs" and "cifs". <p> CIFS parameters are documented with mount.cifs at http://linux.die.net/man/8/mount.cifs For simplicity, when a URI is used to specify a CIFS share, options such as domain,user,password are passed as query parameters.
 * @param uri crresponding to the remote device. Will throw for unsupported scheme.
 * @param imgStoreId
 * @return name of folder in _parent that device was mounted.
 * @throws UnknownHostException
 */
protected String mountUri(URI uri,String nfsVersion) throws UnknownHostException {
  String uriHostIp=getUriHostIp(uri);
  String nfsPath=uriHostIp + "String_Node_Str" + uri.getPath();
  String dir=UUID.nameUUIDFromBytes(nfsPath.getBytes()).toString();
  String localRootPath=_parent + "String_Node_Str" + dir;
  String remoteDevice;
  if (uri.getScheme().equals("String_Node_Str")) {
    remoteDevice="String_Node_Str" + uriHostIp + uri.getPath();
    s_logger.debug("String_Node_Str" + remoteDevice);
  }
 else {
    remoteDevice=nfsPath;
    s_logger.debug("String_Node_Str" + remoteDevice);
  }
  mount(localRootPath,remoteDevice,uri,nfsVersion);
  return dir;
}

Fixed version (ground truth):
/** 
 * Mount remote device named on local file system on subfolder of _parent field. <p> Supported schemes are "nfs" and "cifs". <p> CIFS parameters are documented with mount.cifs at http://linux.die.net/man/8/mount.cifs For simplicity, when a URI is used to specify a CIFS share, options such as domain,user,password are passed as query parameters.
 * @param uri crresponding to the remote device. Will throw for unsupported scheme.
 * @param imgStoreId
 * @return name of folder in _parent that device was mounted.
 * @throws UnknownHostException
 */
protected String mountUri(URI uri,String nfsVersion) throws UnknownHostException {
  String uriHostIp=getUriHostIp(uri);
  String nfsPath=uriHostIp + "String_Node_Str" + uri.getPath();
  String dir=UUID.nameUUIDFromBytes(nfsPath.getBytes(com.cloud.utils.StringUtils.getPreferredCharset())).toString();
  String localRootPath=_parent + "String_Node_Str" + dir;
  String remoteDevice;
  if (uri.getScheme().equals("String_Node_Str")) {
    remoteDevice="String_Node_Str" + uriHostIp + uri.getPath();
    s_logger.debug("String_Node_Str" + remoteDevice);
  }
 else {
    remoteDevice=nfsPath;
    s_logger.debug("String_Node_Str" + remoteDevice);
  }
  mount(localRootPath,remoteDevice,uri,nfsVersion);
  return dir;
}
Program: 105180
Project: 105180
Buggy source:
@SuppressWarnings("String_Node_Str") protected String determineS3TemplateDirectory(final Long accountId,final Long templateId,final String templateUniqueName){
  return join(asList(TEMPLATE_ROOT_DIR,accountId,templateId,templateUniqueName),S3Utils.SEPARATOR);
}

Fixed version (ground truth):
protected String determineS3TemplateDirectory(final Long accountId,final Long templateId,final String templateUniqueName){
  return join(asList(TEMPLATE_ROOT_DIR,accountId,templateId,templateUniqueName),S3Utils.SEPARATOR);
}
Program: 105181
Project: 105181
Buggy source:
@SuppressWarnings("String_Node_Str") protected String determineS3VolumeDirectory(final Long accountId,final Long volId){
  return join(asList(VOLUME_ROOT_DIR,accountId,volId),S3Utils.SEPARATOR);
}

Fixed version (ground truth):
protected String determineS3VolumeDirectory(final Long accountId,final Long volId){
  return join(asList(VOLUME_ROOT_DIR,accountId,volId),S3Utils.SEPARATOR);
}