Program: 97431
Project: 97431
Buggy source:
@Test public void testAdaVCast60ImportOp() throws Exception {
  File dbFile=tempFolder.newFile("String_Node_Str");
  File resultsFolder=tempFolder.newFolder("String_Node_Str");
  Bundle bundle=FrameworkUtil.getBundle(this.getClass());
  copyResource(getURL(bundle,"String_Node_Str"),dbFile);
  copyResource(getURL(bundle,"String_Node_Str"),tempFolder.newFile("String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),tempFolder.newFile("String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),new File(resultsFolder,"String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),new File(resultsFolder,"String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),new File(resultsFolder,"String_Node_Str"));
  VCast60Params params=new VCast60Params(tempFolder.getRoot().getAbsolutePath(),"String_Node_Str",false,dbFile.getAbsolutePath());
  coverageImport=new CoverageImport("String_Node_Str");
  IOperation operation=CoverageImportFactory.createAdaVCast60ImportOp(params,coverageImport);
  Operations.executeWorkAndCheckStatus(operation);
  Assert.assertNotNull(coverageImport);
  Assert.assertFalse(coverageImport.getLog().isErrors());
  Assert.assertEquals(12,coverageImport.getCoverageItems().size());
  Assert.assertEquals(58,coverageImport.getCoveragePercent().intValue());
  Assert.assertEquals(7,coverageImport.getCoverageItemsCovered().size());
  Assert.assertEquals(0,coverageImport.getCoverageItemsCount(CoverageOptionManager.Deactivated_Code));
  Assert.assertEquals(0,coverageImport.getCoverageItemsCount(CoverageOptionManager.Exception_Handling));
  Assert.assertEquals(7,coverageImport.getCoverageItemsCount(CoverageOptionManager.Test_Unit));
  Assert.assertEquals(5,coverageImport.getCoverageItemsCount(CoverageOptionManager.Not_Covered));
  for (  CoverageItem coverageItem : coverageImport.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getName()));
  }
  for (  CoverageItem coverageItem : coverageImport.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getNamespace()));
  }
  for (  CoverageItem coverageItem : coverageImport.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getOrderNumber()));
  }
  coveragePackage=new CoveragePackage("String_Node_Str",CoverageOptionManagerDefault.instance(),new SimpleWorkProductTaskProvider());
  MergeManager mergeManager=new MergeManager(coveragePackage,coverageImport);
  if (mergeManager.getMergeItems(null).size() > 1) {
    int x=0;
    System.err.println("String_Node_Str");
    for (    IMergeItem mergeItem : mergeManager.getMergeItems(null)) {
      System.err.println("String_Node_Str" + x + "String_Node_Str"+ mergeItem);
      x++;
    }
  }
  Assert.assertEquals(1,mergeManager.getMergeItems(null).size());
  Assert.assertEquals(MergeType.Add,mergeManager.getMergeItems(null).iterator().next().getMergeType());
  MergeImportManager importManager=new MergeImportManager(mergeManager);
  XResultData resultData=importManager.importItems(new ISaveable(){
    @Override public Result isEditable(){
      return Result.TrueResult;
    }
    @Override public Result save(    String saveName,    CoverageOptionManager coverageOptionManager){
      return Result.TrueResult;
    }
    @Override public Result save(    Collection<ICoverage> coverages,    String saveName){
      return Result.TrueResult;
    }
    @Override public Result saveImportRecord(    SkynetTransaction transaction,    CoverageImport coverageImport){
      return Result.TrueResult;
    }
    @Override public IOseeBranch getBranch(){
      return CoverageTestUtil.getTestBranch();
    }
  }
,mergeManager.getMergeItems(null));
  Assert.assertEquals(0,resultData.getNumErrors());
  for (  CoverageItem coverageItem : coveragePackage.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getName()));
  }
  for (  CoverageItem coverageItem : coveragePackage.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getNamespace()));
  }
  for (  CoverageItem coverageItem : coveragePackage.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getOrderNumber()));
  }
  CoverageUtil.printCoverageItemDiffs(coveragePackage,coverageImport);
  Assert.assertEquals(12,coveragePackage.getCoverageItems().size());
  Assert.assertEquals(58,coveragePackage.getCoveragePercent().intValue());
  Assert.assertEquals(7,coveragePackage.getCoverageItemsCovered().size());
  Assert.assertEquals(0,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Deactivated_Code));
  Assert.assertEquals(0,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Exception_Handling));
  Assert.assertEquals(7,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Test_Unit));
  Assert.assertEquals(5,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Not_Covered));
  CoveragePackage loadedCp=null;
  if (testWithDb) {
    OseeCoverageStore store=OseeCoveragePackageStore.get(coveragePackage,CoverageTestUtil.getTestBranch());
    String txComment=String.format("String_Node_Str",getClass().getSimpleName(),testName.getMethodName());
    SkynetTransaction transaction=TransactionManager.createTransaction(CoverageTestUtil.getTestBranch(),txComment);
    CoveragePackageEvent coverageEvent=new CoveragePackageEvent(coveragePackage,CoverageEventType.Modified);
    store.save(transaction,coverageEvent,coveragePackage.getCoverageOptionManager());
    store.getArtifact(false).persist(transaction);
    Artifact artifact=ArtifactQuery.getArtifactFromId(coveragePackage.getGuid(),CoverageTestUtil.getTestBranch());
    CoverageTestUtil.registerAsTestArtifact(artifact);
    artifact.persist(transaction);
    OseeCoveragePackageStore packageStore=new OseeCoveragePackageStore(artifact);
    Assert.assertNotNull(packageStore.getArtifact(false));
    loadedCp=packageStore.getCoveragePackage();
    packageStore.getArtifact(false).persist(transaction);
    transaction.execute();
  }
 else {
    loadedCp=coveragePackage;
  }
  Assert.assertEquals(12,loadedCp.getCoverageItems().size());
  Assert.assertEquals(58,loadedCp.getCoveragePercent().intValue());
  Assert.assertEquals(7,loadedCp.getCoverageItemsCovered().size());
  Assert.assertEquals(0,loadedCp.getCoverageItemsCount(CoverageOptionManager.Deactivated_Code));
  Assert.assertEquals(0,loadedCp.getCoverageItemsCount(CoverageOptionManager.Exception_Handling));
  Assert.assertEquals(7,loadedCp.getCoverageItemsCount(CoverageOptionManager.Test_Unit));
  Assert.assertEquals(5,loadedCp.getCoverageItemsCount(CoverageOptionManager.Not_Covered));
}

Fixed version (ground truth):
@Test public void testAdaVCast60ImportOp() throws Exception {
  File dbFile=tempFolder.newFile("String_Node_Str");
  File resultsFolder=tempFolder.newFolder("String_Node_Str");
  Bundle bundle=FrameworkUtil.getBundle(this.getClass());
  copyResource(getURL(bundle,"String_Node_Str"),dbFile);
  copyResource(getURL(bundle,"String_Node_Str"),tempFolder.newFile("String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),tempFolder.newFile("String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),new File(resultsFolder,"String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),new File(resultsFolder,"String_Node_Str"));
  copyResource(getURL(bundle,"String_Node_Str"),new File(resultsFolder,"String_Node_Str"));
  VCast60Params params=new VCast60Params(tempFolder.getRoot().getAbsolutePath() + "String_Node_Str","String_Node_Str",false,dbFile.getName());
  coverageImport=new CoverageImport("String_Node_Str");
  IOperation operation=CoverageImportFactory.createAdaVCast60ImportOp(params,coverageImport);
  Operations.executeWorkAndCheckStatus(operation);
  Assert.assertNotNull(coverageImport);
  Assert.assertFalse(coverageImport.getLog().isErrors());
  Assert.assertEquals(12,coverageImport.getCoverageItems().size());
  Assert.assertEquals(58,coverageImport.getCoveragePercent().intValue());
  Assert.assertEquals(7,coverageImport.getCoverageItemsCovered().size());
  Assert.assertEquals(0,coverageImport.getCoverageItemsCount(CoverageOptionManager.Deactivated_Code));
  Assert.assertEquals(0,coverageImport.getCoverageItemsCount(CoverageOptionManager.Exception_Handling));
  Assert.assertEquals(7,coverageImport.getCoverageItemsCount(CoverageOptionManager.Test_Unit));
  Assert.assertEquals(5,coverageImport.getCoverageItemsCount(CoverageOptionManager.Not_Covered));
  for (  CoverageItem coverageItem : coverageImport.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getName()));
  }
  for (  CoverageItem coverageItem : coverageImport.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getNamespace()));
  }
  for (  CoverageItem coverageItem : coverageImport.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getOrderNumber()));
  }
  coveragePackage=new CoveragePackage("String_Node_Str",CoverageOptionManagerDefault.instance(),new SimpleWorkProductTaskProvider());
  MergeManager mergeManager=new MergeManager(coveragePackage,coverageImport);
  if (mergeManager.getMergeItems(null).size() > 1) {
    int x=0;
    System.err.println("String_Node_Str");
    for (    IMergeItem mergeItem : mergeManager.getMergeItems(null)) {
      System.err.println("String_Node_Str" + x + "String_Node_Str"+ mergeItem);
      x++;
    }
  }
  Assert.assertEquals(1,mergeManager.getMergeItems(null).size());
  Assert.assertEquals(MergeType.Add,mergeManager.getMergeItems(null).iterator().next().getMergeType());
  MergeImportManager importManager=new MergeImportManager(mergeManager);
  XResultData resultData=importManager.importItems(new ISaveable(){
    @Override public Result isEditable(){
      return Result.TrueResult;
    }
    @Override public Result save(    String saveName,    CoverageOptionManager coverageOptionManager){
      return Result.TrueResult;
    }
    @Override public Result save(    Collection<ICoverage> coverages,    String saveName){
      return Result.TrueResult;
    }
    @Override public Result saveImportRecord(    SkynetTransaction transaction,    CoverageImport coverageImport){
      return Result.TrueResult;
    }
    @Override public IOseeBranch getBranch(){
      return CoverageTestUtil.getTestBranch();
    }
  }
,mergeManager.getMergeItems(null));
  Assert.assertEquals(0,resultData.getNumErrors());
  for (  CoverageItem coverageItem : coveragePackage.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getName()));
  }
  for (  CoverageItem coverageItem : coveragePackage.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getNamespace()));
  }
  for (  CoverageItem coverageItem : coveragePackage.getCoverageItems()) {
    Assert.assertTrue(Strings.isValid(coverageItem.getOrderNumber()));
  }
  CoverageUtil.printCoverageItemDiffs(coveragePackage,coverageImport);
  Assert.assertEquals(12,coveragePackage.getCoverageItems().size());
  Assert.assertEquals(58,coveragePackage.getCoveragePercent().intValue());
  Assert.assertEquals(7,coveragePackage.getCoverageItemsCovered().size());
  Assert.assertEquals(0,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Deactivated_Code));
  Assert.assertEquals(0,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Exception_Handling));
  Assert.assertEquals(7,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Test_Unit));
  Assert.assertEquals(5,coveragePackage.getCoverageItemsCount(CoverageOptionManager.Not_Covered));
  CoveragePackage loadedCp=null;
  if (testWithDb) {
    OseeCoverageStore store=OseeCoveragePackageStore.get(coveragePackage,CoverageTestUtil.getTestBranch());
    String txComment=String.format("String_Node_Str",getClass().getSimpleName(),testName.getMethodName());
    SkynetTransaction transaction=TransactionManager.createTransaction(CoverageTestUtil.getTestBranch(),txComment);
    CoveragePackageEvent coverageEvent=new CoveragePackageEvent(coveragePackage,CoverageEventType.Modified);
    store.save(transaction,coverageEvent,coveragePackage.getCoverageOptionManager());
    store.getArtifact(false).persist(transaction);
    Artifact artifact=ArtifactQuery.getArtifactFromId(coveragePackage.getGuid(),CoverageTestUtil.getTestBranch());
    CoverageTestUtil.registerAsTestArtifact(artifact);
    artifact.persist(transaction);
    OseeCoveragePackageStore packageStore=new OseeCoveragePackageStore(artifact);
    Assert.assertNotNull(packageStore.getArtifact(false));
    loadedCp=packageStore.getCoveragePackage();
    packageStore.getArtifact(false).persist(transaction);
    transaction.execute();
  }
 else {
    loadedCp=coveragePackage;
  }
  Assert.assertEquals(12,loadedCp.getCoverageItems().size());
  Assert.assertEquals(58,loadedCp.getCoveragePercent().intValue());
  Assert.assertEquals(7,loadedCp.getCoverageItemsCovered().size());
  Assert.assertEquals(0,loadedCp.getCoverageItemsCount(CoverageOptionManager.Deactivated_Code));
  Assert.assertEquals(0,loadedCp.getCoverageItemsCount(CoverageOptionManager.Exception_Handling));
  Assert.assertEquals(7,loadedCp.getCoverageItemsCount(CoverageOptionManager.Test_Unit));
  Assert.assertEquals(5,loadedCp.getCoverageItemsCount(CoverageOptionManager.Not_Covered));
}