nus-yam/ex-repair huggingface dataset:
Program: 49379
Project: 49379
Buggy source:
@Test public void testImportRecordDeleteWithLogging() throws IOException, ImporterException {
  EventSink es=mock(EventSink.class);
  ExporterMetadataCurator ec=mock(ExporterMetadataCurator.class);
  SubscriptionCurator sc=mock(SubscriptionCurator.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,sc,null,null,null,i18n,es,null,null,null,null,null,ec,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  ExporterMetadata metadata=new ExporterMetadata();
  when(ec.lookupByTypeAndOwner(ExporterMetadata.TYPE_PER_USER,owner)).thenReturn(metadata);
  when(sc.listByOwner(owner)).thenReturn(new ArrayList<Subscription>());
  thisOwnerResource.undoImports(owner.getKey(),new UserPrincipal("String_Node_Str",null,true));
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  assertTrue(records.size() == 1);
  ImportRecord ir=records.get(0);
  assertTrue(ir.getStatus() == ImportRecord.Status.DELETE);
}

Fixed version (ground truth):
@Test public void testImportRecordDeleteWithLogging() throws IOException, ImporterException {
  EventSink es=mock(EventSink.class);
  ExporterMetadataCurator ec=mock(ExporterMetadataCurator.class);
  SubscriptionCurator sc=mock(SubscriptionCurator.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,sc,null,null,null,i18n,es,null,null,null,null,this.poolManager,ec,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  ExporterMetadata metadata=new ExporterMetadata();
  when(ec.lookupByTypeAndOwner(ExporterMetadata.TYPE_PER_USER,owner)).thenReturn(metadata);
  when(sc.listByOwner(owner)).thenReturn(new ArrayList<Subscription>());
  thisOwnerResource.undoImports(owner.getKey(),new UserPrincipal("String_Node_Str",null,true));
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  assertTrue(records.size() == 1);
  ImportRecord ir=records.get(0);
  assertTrue(ir.getStatus() == ImportRecord.Status.DELETE);
}
Program: 49380
Project: 49380
Buggy source:
@Transactional public Content createOrUpdate(Content c){
  Content existing=this.lookupById(c.getOwner(),c.getId());
  if (existing == null) {
    create(c);
    return c;
  }
  return merge(c);
}

Fixed version (ground truth):
@Transactional public Content createOrUpdate(Content c){
  Content existing=this.lookupById(c.getOwner(),c.getId());
  if (existing == null) {
    create(c);
    return c;
  }
  copy(c,existing);
  return merge(existing);
}
Program: 49381
Project: 49381
Buggy source:
public Set<ProductAttribute> getProductAttributes(){
  if (this.isStacked()) {
    return this.getStackedProductAttributes();
  }
  return this.getProduct() != null ? this.getProduct().getAttributes() : new HashSet<ProductAttribute>();
}

Fixed version (ground truth):
public Set<ProductAttribute> getProductAttributes(){
  return this.getProduct() != null ? this.getProduct().getAttributes() : new HashSet<ProductAttribute>();
}
Program: 49383
Project: 49383
Buggy source:
public StackedSubPoolValueAccumulator(Pool stackedSubPool,List<Entitlement> stackedEnts){
  for (  Entitlement nextStacked : stackedEnts) {
    Pool nextStackedPool=nextStacked.getPool();
    updateEldest(nextStacked);
    accumulateDateRange(nextStacked);
    updateEldestWithVirtLimit(nextStacked);
    accumulateProvidedProducts(stackedSubPool,nextStackedPool);
    accumulateProductAttributes(stackedSubPool,nextStackedPool);
  }
}

Fixed version (ground truth):
public StackedSubPoolValueAccumulator(Pool stackedSubPool,List<Entitlement> stackedEnts){
  for (  Entitlement nextStacked : stackedEnts) {
    Pool nextStackedPool=nextStacked.getPool();
    updateEldest(nextStacked);
    accumulateDateRange(nextStacked);
    updateEldestWithVirtLimit(nextStacked);
    accumulateProvidedProducts(stackedSubPool,nextStackedPool);
  }
}
Program: 49384
Project: 49384
Buggy source:
@Test public void mergedProductAttributes(){
  stackedEnts.add(createEntFromPool(pool1));
  stackedEnts.add(createEntFromPool(pool3));
  PoolUpdate update=poolRules.updatePoolFromStack(stackDerivedPool,null);
  assertTrue(update.changed());
  assertTrue(update.getProductAttributesChanged());
  assertEquals(6,stackDerivedPool.getProductAttributes().size());
  assertEquals("String_Node_Str",stackDerivedPool.getProductAttributeValue("String_Node_Str"));
  assertEquals("String_Node_Str",stackDerivedPool.getProductAttributeValue("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void mergedProductAttributes(){
  Entitlement ent1=createEntFromPool(pool1);
  ent1.setCreated(new Date(System.currentTimeMillis() - 86400000));
  stackedEnts.add(ent1);
  stackedEnts.add(createEntFromPool(pool3));
  PoolUpdate update=poolRules.updatePoolFromStack(stackDerivedPool,null);
  assertTrue(update.changed());
  assertTrue(update.getProductAttributesChanged());
  assertEquals(pool1.getProductAttributes(),stackDerivedPool.getProductAttributes());
}
Program: 49387
Project: 49387
Buggy source:
public void store(Set<Product> products){
  for (  Product importedProduct : products) {
    for (    ProductContent content : importedProduct.getProductContent()) {
      Content c=content.getContent();
      if (StringUtils.isBlank(c.getVendor())) {
        c.setVendor("String_Node_Str");
      }
      contentCurator.createOrUpdate(c);
    }
    curator.createOrUpdate(importedProduct);
  }
}

Fixed version (ground truth):
public void store(Set<Product> products,Owner o){
  for (  Product importedProduct : products) {
    for (    ProductContent content : importedProduct.getProductContent()) {
      Content c=content.getContent();
      if (StringUtils.isBlank(c.getVendor())) {
        c.setVendor("String_Node_Str");
      }
      c.setOwner(o);
      contentCurator.createOrUpdate(c);
    }
  }
}
Program: 49388
Project: 49388
Buggy source:
@Test public void testNewProductCreated() throws Exception {
  Product product=TestUtil.createProduct(owner);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  when(productCuratorMock.lookupById(product.getOwner(),product.getId())).thenReturn(null);
  importer.store(storeThese);
  verify(productCuratorMock).createOrUpdate(created);
}

Fixed version (ground truth):
@Test public void testNewProductCreated() throws Exception {
  Product product=TestUtil.createProduct(owner);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  when(productCuratorMock.lookupById(product.getOwner(),product.getId())).thenReturn(null);
  importer.store(storeThese,owner);
  verify(productCuratorMock).createOrUpdate(created);
}
Program: 49389
Project: 49389
Buggy source:
@Test public void testVendorSetToUnknown() throws Exception {
  Product product=TestUtil.createProduct(owner);
  addNoVendorContentTo(product);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  Content c=created.getProductContent().iterator().next().getContent();
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  importer.store(storeThese);
  verify(contentCuratorMock).createOrUpdate(c);
  assertEquals("String_Node_Str",c.getVendor());
}

Fixed version (ground truth):
@Test public void testVendorSetToUnknown() throws Exception {
  Product product=TestUtil.createProduct(owner);
  addNoVendorContentTo(product);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  Content c=created.getProductContent().iterator().next().getContent();
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  importer.store(storeThese,owner);
  verify(contentCuratorMock).createOrUpdate(c);
  assertEquals("String_Node_Str",c.getVendor());
}
Program: 49390
Project: 49390
Buggy source:
@Test public void testExistingProductUpdated() throws Exception {
  Product product=TestUtil.createProduct(owner);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  String newProductName="String_Node_Str";
  created.setName(newProductName);
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  when(productCuratorMock.lookupById(product.getOwner(),product.getId())).thenReturn(product);
  importer.store(storeThese);
  verify(productCuratorMock).createOrUpdate(created);
}

Fixed version (ground truth):
@Test public void testExistingProductUpdated() throws Exception {
  Product product=TestUtil.createProduct(owner);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  String newProductName="String_Node_Str";
  created.setName(newProductName);
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  when(productCuratorMock.lookupById(product.getOwner(),product.getId())).thenReturn(product);
  importer.store(storeThese,owner);
  verify(productCuratorMock).createOrUpdate(created);
}
Program: 49391
Project: 49391
Buggy source:
@Test public void testContentCreated() throws Exception {
  Product product=TestUtil.createProduct(owner);
  addContentTo(product);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  Content c=created.getProductContent().iterator().next().getContent();
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  importer.store(storeThese);
  verify(contentCuratorMock).createOrUpdate(c);
  assertEquals(new Long(1000),c.getMetadataExpire());
}

Fixed version (ground truth):
@Test public void testContentCreated() throws Exception {
  Product product=TestUtil.createProduct(owner);
  addContentTo(product);
  String json=getJsonForProduct(product);
  Reader reader=new StringReader(json);
  Product created=importer.createObject(mapper,reader);
  Content c=created.getProductContent().iterator().next().getContent();
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(created);
  importer.store(storeThese,owner);
  verify(contentCuratorMock).createOrUpdate(c);
  assertEquals(new Long(1000),c.getMetadataExpire());
}
Program: 49392
Project: 49392
Buggy source:
@Test public void testExistingProductContentAdded() throws Exception {
  Owner owner=new Owner("String_Node_Str");
  Product oldProduct=TestUtil.createProduct("String_Node_Str","String_Node_Str",owner);
  Product newProduct=TestUtil.createProduct("String_Node_Str","String_Node_Str",owner);
  addContentTo(newProduct);
  Content c=newProduct.getProductContent().iterator().next().getContent();
  when(productCuratorMock.find(oldProduct.getUuid())).thenReturn(oldProduct);
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(newProduct);
  importer.store(storeThese);
  verify(productCuratorMock).createOrUpdate(newProduct);
  verify(contentCuratorMock).createOrUpdate(c);
}

Fixed version (ground truth):
@Test public void testExistingProductContentAdded() throws Exception {
  Owner owner=new Owner("String_Node_Str");
  Product oldProduct=TestUtil.createProduct("String_Node_Str","String_Node_Str",owner);
  Product newProduct=TestUtil.createProduct("String_Node_Str","String_Node_Str",owner);
  addContentTo(newProduct);
  Content c=newProduct.getProductContent().iterator().next().getContent();
  when(productCuratorMock.find(oldProduct.getUuid())).thenReturn(oldProduct);
  Set<Product> storeThese=new HashSet<Product>();
  storeThese.add(newProduct);
  importer.store(storeThese,owner);
  verify(productCuratorMock).createOrUpdate(newProduct);
  verify(contentCuratorMock).createOrUpdate(c);
}
Program: 49393
Project: 49393
Buggy source:
public void copy(Content src,Content dest){
  if (src.getId() == null ? dest.getId() != null : !src.getId().equals(dest.getId())) {
    throw new RuntimeException(i18n.tr("String_Node_Str",src.getId(),dest.getId()));
  }
  dest.setName(src.getName());
  dest.setArches(src.getArches());
  dest.setContentUrl(src.getContentUrl());
  dest.setGpgUrl(src.getGpgUrl());
  dest.setLabel(src.getLabel());
  dest.setMetadataExpire(src.getMetadataExpire());
  dest.setModifiedProductIds(src.getModifiedProductIds());
}

Fixed version (ground truth):
public void copy(Content src,Content dest){
  if (src.getId() == null ? dest.getId() != null : !src.getId().equals(dest.getId())) {
    throw new RuntimeException(i18n.tr("String_Node_Str",src.getId(),dest.getId()));
  }
  dest.setName(src.getName());
  dest.setArches(src.getArches());
  dest.setContentUrl(src.getContentUrl());
  dest.setGpgUrl(src.getGpgUrl());
  dest.setLabel(src.getLabel());
  dest.setMetadataExpire(src.getMetadataExpire());
  dest.setModifiedProductIds(src.getModifiedProductIds());
  dest.setType(src.getType());
}
Program: 49394
Project: 49394
Buggy source:
public void copy(Content src,Content dest){
  if (src.getId() == null ? dest.getId() != null : !src.getId().equals(dest.getId())) {
    throw new RuntimeException(i18n.tr("String_Node_Str",src.getId(),dest.getId()));
  }
  dest.setName(src.getName());
  dest.setArches(src.getArches());
  dest.setContentUrl(src.getContentUrl());
  dest.setGpgUrl(src.getGpgUrl());
  dest.setLabel(src.getLabel());
  dest.setMetadataExpire(src.getMetadataExpire());
  dest.setModifiedProductIds(src.getModifiedProductIds());
  dest.setType(src.getType());
}

Fixed version (ground truth):
public void copy(Content src,Content dest){
  if (src.getId() == null ? dest.getId() != null : !src.getId().equals(dest.getId())) {
    throw new RuntimeException(i18n.tr("String_Node_Str",src.getId(),dest.getId()));
  }
  dest.setName(src.getName());
  dest.setArches(src.getArches());
  dest.setContentUrl(src.getContentUrl());
  dest.setGpgUrl(src.getGpgUrl());
  dest.setLabel(src.getLabel());
  dest.setMetadataExpire(src.getMetadataExpire());
  dest.setModifiedProductIds(src.getModifiedProductIds());
  dest.setType(src.getType());
  dest.setVendor(src.getVendor());
  dest.setRequiredTags(src.getRequiredTags());
  dest.setReleaseVer(src.getReleaseVer());
}
Program: 49395
Project: 49395
Buggy source:
@Test public void upstreamConsumers(){
  Principal p=mock(Principal.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  UpstreamConsumer upstream=mock(UpstreamConsumer.class);
  Owner owner=mock(Owner.class);
  OwnerResource ownerres=new OwnerResource(oc,null,null,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null);
  when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(owner);
  when(owner.getUpstreamConsumer()).thenReturn(upstream);
  List<UpstreamConsumer> results=ownerres.getUpstreamConsumers(p,"String_Node_Str");
  assertNotNull(results);
  assertEquals(1,results.size());
}

Fixed version (ground truth):
@Test public void upstreamConsumers(){
  Principal p=mock(Principal.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  UpstreamConsumer upstream=mock(UpstreamConsumer.class);
  Owner owner=mock(Owner.class);
  OwnerResource ownerres=new OwnerResource(oc,null,null,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(owner);
  when(owner.getUpstreamConsumer()).thenReturn(upstream);
  List<UpstreamConsumer> results=ownerres.getUpstreamConsumers(p,"String_Node_Str");
  assertNotNull(results);
  assertEquals(1,results.size());
}
Program: 49396
Project: 49396
Buggy source:
private Pool doTestEntitlementsRevocationCommon(long subQ,int e1,int e2,boolean fifo) throws ParseException {
  Product prod=TestUtil.createProduct(owner);
  productCurator.create(prod);
  Pool pool=createPoolAndSub(createOwner(),prod,1000L,TestUtil.createDate(2009,11,30),TestUtil.createDate(2015,11,30));
  Owner owner=pool.getOwner();
  Consumer consumer=createConsumer(owner);
  Consumer consumer1=createConsumer(owner);
  Subscription sub=this.subCurator.find(pool.getSubscriptionId());
  sub.setQuantity(subQ);
  this.subCurator.merge(sub);
  pool=this.poolCurator.find(pool.getId());
  createEntitlementWithQ(pool,owner,consumer,e1,"String_Node_Str");
  createEntitlementWithQ(pool,owner,consumer1,e2,"String_Node_Str");
  assertEquals(pool.getConsumed(),Long.valueOf(e1 + e2));
  this.config.setProperty(ConfigProperties.REVOKE_ENTITLEMENT_IN_FIFO_ORDER,fifo ? "String_Node_Str" : "String_Node_Str");
  poolManager.getRefresher(subAdapter).add(owner).run();
  pool=poolCurator.find(pool.getId());
  return pool;
}

Fixed version (ground truth):
private Pool doTestEntitlementsRevocationCommon(long subQ,int e1,int e2,boolean fifo) throws ParseException {
  Product prod=TestUtil.createProduct(owner);
  productCurator.create(prod);
  Pool pool=createPoolAndSub(owner,prod,1000L,TestUtil.createDate(2009,11,30),TestUtil.createDate(2015,11,30));
  Owner owner=pool.getOwner();
  Consumer consumer=createConsumer(owner);
  Consumer consumer1=createConsumer(owner);
  Subscription sub=this.subCurator.find(pool.getSubscriptionId());
  sub.setQuantity(subQ);
  this.subCurator.merge(sub);
  pool=this.poolCurator.find(pool.getId());
  createEntitlementWithQ(pool,owner,consumer,e1,"String_Node_Str");
  createEntitlementWithQ(pool,owner,consumer1,e2,"String_Node_Str");
  assertEquals(pool.getConsumed(),Long.valueOf(e1 + e2));
  this.config.setProperty(ConfigProperties.REVOKE_ENTITLEMENT_IN_FIFO_ORDER,fifo ? "String_Node_Str" : "String_Node_Str");
  poolManager.getRefresher(subAdapter).add(owner).run();
  pool=poolCurator.find(pool.getId());
  return pool;
}
Program: 49397
Project: 49397
Buggy source:
@Test public void testImportRecordDeleteWithLogging() throws IOException, ImporterException {
  EventSink es=mock(EventSink.class);
  ExporterMetadataCurator ec=mock(ExporterMetadataCurator.class);
  SubscriptionCurator sc=mock(SubscriptionCurator.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,sc,null,null,null,i18n,es,null,null,null,null,null,ec,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null);
  ExporterMetadata metadata=new ExporterMetadata();
  when(ec.lookupByTypeAndOwner(ExporterMetadata.TYPE_PER_USER,owner)).thenReturn(metadata);
  when(sc.listByOwner(owner)).thenReturn(new ArrayList<Subscription>());
  thisOwnerResource.undoImports(owner.getKey(),new UserPrincipal("String_Node_Str",null,true));
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  assertTrue(records.size() == 1);
  ImportRecord ir=records.get(0);
  assertTrue(ir.getStatus() == ImportRecord.Status.DELETE);
}

Fixed version (ground truth):
@Test public void testImportRecordDeleteWithLogging() throws IOException, ImporterException {
  EventSink es=mock(EventSink.class);
  ExporterMetadataCurator ec=mock(ExporterMetadataCurator.class);
  SubscriptionCurator sc=mock(SubscriptionCurator.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,sc,null,null,null,i18n,es,null,null,null,null,null,ec,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  ExporterMetadata metadata=new ExporterMetadata();
  when(ec.lookupByTypeAndOwner(ExporterMetadata.TYPE_PER_USER,owner)).thenReturn(metadata);
  when(sc.listByOwner(owner)).thenReturn(new ArrayList<Subscription>());
  thisOwnerResource.undoImports(owner.getKey(),new UserPrincipal("String_Node_Str",null,true));
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  assertTrue(records.size() == 1);
  ImportRecord ir=records.get(0);
  assertTrue(ir.getStatus() == ImportRecord.Status.DELETE);
}
Program: 49398
Project: 49398
Buggy source:
@Test public void testImportRecordFailureWithFilename() throws IOException, ImporterException {
  Importer importer=mock(Importer.class);
  EventSink es=mock(EventSink.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,null,null,null,null,i18n,es,null,null,null,importer,null,null,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null);
  MultipartInput input=mock(MultipartInput.class);
  InputPart part=mock(InputPart.class);
  File archive=mock(File.class);
  List<InputPart> parts=new ArrayList<InputPart>();
  parts.add(part);
  MultivaluedMap<String,String> mm=new MultivaluedMapImpl<String,String>();
  List<String> contDis=new ArrayList<String>();
  contDis.add("String_Node_Str");
  mm.put("String_Node_Str",contDis);
  when(input.getParts()).thenReturn(parts);
  when(part.getHeaders()).thenReturn(mm);
  when(part.getBody(any(GenericType.class))).thenReturn(archive);
  when(importer.loadExport(eq(owner),any(File.class),any(ConflictOverrides.class))).thenThrow(new ImporterException("String_Node_Str"));
  try {
    thisOwnerResource.importManifest(owner.getKey(),new String[]{},input);
  }
 catch (  IseException ise) {
  }
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  ImportRecord ir=records.get(0);
  assertEquals("String_Node_Str",ir.getFileName());
  assertEquals(owner,ir.getOwner());
  assertEquals(ImportRecord.Status.FAILURE,ir.getStatus());
  assertEquals("String_Node_Str",ir.getStatusMessage());
}

Fixed version (ground truth):
@Test public void testImportRecordFailureWithFilename() throws IOException, ImporterException {
  Importer importer=mock(Importer.class);
  EventSink es=mock(EventSink.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,null,null,null,null,i18n,es,null,null,null,importer,null,null,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  MultipartInput input=mock(MultipartInput.class);
  InputPart part=mock(InputPart.class);
  File archive=mock(File.class);
  List<InputPart> parts=new ArrayList<InputPart>();
  parts.add(part);
  MultivaluedMap<String,String> mm=new MultivaluedMapImpl<String,String>();
  List<String> contDis=new ArrayList<String>();
  contDis.add("String_Node_Str");
  mm.put("String_Node_Str",contDis);
  when(input.getParts()).thenReturn(parts);
  when(part.getHeaders()).thenReturn(mm);
  when(part.getBody(any(GenericType.class))).thenReturn(archive);
  when(importer.loadExport(eq(owner),any(File.class),any(ConflictOverrides.class))).thenThrow(new ImporterException("String_Node_Str"));
  try {
    thisOwnerResource.importManifest(owner.getKey(),new String[]{},input);
  }
 catch (  IseException ise) {
  }
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  ImportRecord ir=records.get(0);
  assertEquals("String_Node_Str",ir.getFileName());
  assertEquals(owner,ir.getOwner());
  assertEquals(ImportRecord.Status.FAILURE,ir.getStatus());
  assertEquals("String_Node_Str",ir.getStatusMessage());
}
Program: 49399
Project: 49399
Buggy source:
@Test(expected=BadRequestException.class) public void testActivationKeyNameUnique(){
  ActivationKey ak=mock(ActivationKey.class);
  ActivationKey akOld=mock(ActivationKey.class);
  ActivationKeyCurator akc=mock(ActivationKeyCurator.class);
  Owner o=mock(Owner.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  when(ak.getName()).thenReturn("String_Node_Str");
  when(akc.lookupForOwner(eq("String_Node_Str"),eq(o))).thenReturn(akOld);
  when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(o);
  OwnerResource or=new OwnerResource(oc,null,akc,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null);
  or.createActivationKey("String_Node_Str",ak);
}

Fixed version (ground truth):
@Test(expected=BadRequestException.class) public void testActivationKeyNameUnique(){
  ActivationKey ak=mock(ActivationKey.class);
  ActivationKey akOld=mock(ActivationKey.class);
  ActivationKeyCurator akc=mock(ActivationKeyCurator.class);
  Owner o=mock(Owner.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  when(ak.getName()).thenReturn("String_Node_Str");
  when(akc.lookupForOwner(eq("String_Node_Str"),eq(o))).thenReturn(akOld);
  when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(o);
  OwnerResource or=new OwnerResource(oc,null,akc,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  or.createActivationKey("String_Node_Str",ak);
}
Program: 49400
Project: 49400
Buggy source:
@Test public void testImportRecordSuccessWithFilename() throws IOException, ImporterException {
  Importer importer=mock(Importer.class);
  EventSink es=mock(EventSink.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,null,null,null,null,i18n,es,null,null,null,importer,null,null,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null);
  MultipartInput input=mock(MultipartInput.class);
  InputPart part=mock(InputPart.class);
  File archive=mock(File.class);
  List<InputPart> parts=new ArrayList<InputPart>();
  parts.add(part);
  MultivaluedMap<String,String> mm=new MultivaluedMapImpl<String,String>();
  List<String> contDis=new ArrayList<String>();
  contDis.add("String_Node_Str");
  mm.put("String_Node_Str",contDis);
  when(input.getParts()).thenReturn(parts);
  when(part.getHeaders()).thenReturn(mm);
  when(part.getBody(any(GenericType.class))).thenReturn(archive);
  when(importer.loadExport(eq(owner),any(File.class),any(ConflictOverrides.class))).thenReturn(new HashMap<String,Object>());
  thisOwnerResource.importManifest(owner.getKey(),new String[]{},input);
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  ImportRecord ir=records.get(0);
  assertEquals("String_Node_Str",ir.getFileName());
  assertEquals(owner,ir.getOwner());
  assertEquals(ImportRecord.Status.SUCCESS,ir.getStatus());
}

Fixed version (ground truth):
@Test public void testImportRecordSuccessWithFilename() throws IOException, ImporterException {
  Importer importer=mock(Importer.class);
  EventSink es=mock(EventSink.class);
  OwnerResource thisOwnerResource=new OwnerResource(ownerCurator,null,null,null,null,i18n,es,null,null,null,importer,null,null,null,importRecordCurator,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null);
  MultipartInput input=mock(MultipartInput.class);
  InputPart part=mock(InputPart.class);
  File archive=mock(File.class);
  List<InputPart> parts=new ArrayList<InputPart>();
  parts.add(part);
  MultivaluedMap<String,String> mm=new MultivaluedMapImpl<String,String>();
  List<String> contDis=new ArrayList<String>();
  contDis.add("String_Node_Str");
  mm.put("String_Node_Str",contDis);
  when(input.getParts()).thenReturn(parts);
  when(part.getHeaders()).thenReturn(mm);
  when(part.getBody(any(GenericType.class))).thenReturn(archive);
  when(importer.loadExport(eq(owner),any(File.class),any(ConflictOverrides.class))).thenReturn(new HashMap<String,Object>());
  thisOwnerResource.importManifest(owner.getKey(),new String[]{},input);
  List<ImportRecord> records=importRecordCurator.findRecords(owner);
  ImportRecord ir=records.get(0);
  assertEquals("String_Node_Str",ir.getFileName());
  assertEquals(owner,ir.getOwner());
  assertEquals(ImportRecord.Status.SUCCESS,ir.getStatus());
}
Program: 49401
Project: 49401
Buggy source:
@Override public String getHref(){
  return "String_Node_Str" + getOwner().getKey() + "String_Node_Str"+ getId();
}

Fixed version (ground truth):
@Override public String getHref(){
  if (getOwner() == null) {
    return "String_Node_Str";
  }
  return "String_Node_Str" + getOwner().getKey() + "String_Node_Str"+ getId();
}
Program: 49403
Project: 49403
Buggy source:
/** 
 * Add a product that has been changed to be refreshed globally. Will be used to lookup any subscription using the product, either as a SKU or a provided product, and trigger a refresh for that specific subscription. WARNING: Should only be used in upstream production environments, downstream should always be driven by manifest import, which should never trigger a global refresh for other orgs.
 * @param product
 * @return
 */
public Refresher add(Product product){
  products.add(product);
  return this;
}

Fixed version (ground truth):
/** 
 * Add a product that has been changed to be refreshed globally. Will be used to lookup any subscription using the product, either as a SKU or a provided product, and trigger a refresh for that specific subscription. WARNING: Should only be used in upstream production environments, downstream should always be driven by manifest import, which should never trigger a global refresh for other orgs.
 * @param product
 * @return this Refresher instance
 */
public Refresher add(Product product){
  products.add(product);
  return this;
}
Program: 49405
Project: 49405
Buggy source:
/** 
 * Lookup all pools for subscriptions which are not in the given list of subscription IDs. Used for pool cleanup during refresh.
 * @param owner
 * @param expectedSubIds Full list of all expected subscription IDs.
 * @return
 */
@SuppressWarnings("String_Node_Str") public List<Pool> getPoolsFromBadSubs(Owner owner,Collection<String> expectedSubIds){
  Criteria crit=currentSession().createCriteria(Pool.class).add(Restrictions.eq("String_Node_Str",owner));
  if (!expectedSubIds.isEmpty()) {
    crit.createAlias("String_Node_Str","String_Node_Str");
    crit.add(Restrictions.and(Restrictions.not(Restrictions.in("String_Node_Str",expectedSubIds)),Restrictions.isNotNull("String_Node_Str")));
  }
  crit.addOrder(Order.asc("String_Node_Str"));
  return crit.list();
}

Fixed version (ground truth):
/** 
 * Lookup all pools for subscriptions which are not in the given list of subscription IDs. Used for pool cleanup during refresh.
 * @param owner
 * @param expectedSubIds Full list of all expected subscription IDs.
 * @return a list of pools for subscriptions not matching the specified subscription list
 */
@SuppressWarnings("String_Node_Str") public List<Pool> getPoolsFromBadSubs(Owner owner,Collection<String> expectedSubIds){
  Criteria crit=currentSession().createCriteria(Pool.class).add(Restrictions.eq("String_Node_Str",owner));
  if (!expectedSubIds.isEmpty()) {
    crit.createAlias("String_Node_Str","String_Node_Str");
    crit.add(Restrictions.and(Restrictions.not(Restrictions.in("String_Node_Str",expectedSubIds)),Restrictions.isNotNull("String_Node_Str")));
  }
  crit.addOrder(Order.asc("String_Node_Str"));
  return crit.list();
}
Program: 49406
Project: 49406
Buggy source:
/** 
 * @param owner owner to lookup product for
 * @param id Product ID to lookup. (note: not the database ID)
 * @return the Product which matches the given id.
 */
@Transactional public Product lookupById(String ownerId,String productId){
  return (Product)currentSession().createCriteria(Product.class).add(Restrictions.eq("String_Node_Str",ownerId)).add(Restrictions.eq("String_Node_Str",productId)).uniqueResult();
}

Fixed version (ground truth):
/** 
 * @param ownerId The ID of the owner for which to lookup a product
 * @param productId The ID of the product to lookup. (note: not the database ID)
 * @return the Product which matches the given id.
 */
@Transactional public Product lookupById(String ownerId,String productId){
  return (Product)currentSession().createCriteria(Product.class).add(Restrictions.eq("String_Node_Str",ownerId)).add(Restrictions.eq("String_Node_Str",productId)).uniqueResult();
}
Program: 49408
Project: 49408
Buggy source:
@Override @Transactional public void regenerateCertificatesOf(String productUuid,boolean lazy){
  Product product=this.productCurator.find(productUuid);
  if (product != null) {
    this.regenerateCertificatesOf(product.getOwner(),product.getId(),lazy);
  }
}

Fixed version (ground truth):
@Override @Transactional public void regenerateCertificatesOf(Owner owner,String productId,boolean lazy){
  List<Pool> poolsForProduct=this.listAvailableEntitlementPools(null,null,owner,productId,new Date(),false,false,new PoolFilterBuilder(),null).getPageData();
  for (  Pool pool : poolsForProduct) {
    regenerateCertificatesOf(pool.getEntitlements(),lazy);
  }
}
Program: 49409
Project: 49409
Buggy source:
void regenerateCertificatesOf(String productUuid,boolean lazy);

Fixed version (ground truth):
void regenerateCertificatesOf(Owner owner,String productId,boolean lazy);
Program: 49410
Project: 49410
Buggy source:
@Override public void toExecute(JobExecutionContext arg0) throws JobExecutionException {
  String productUuid=arg0.getJobDetail().getJobDataMap().getString(PROD_UUID);
  boolean lazy=arg0.getJobDetail().getJobDataMap().getBoolean(LAZY_REGEN);
  this.poolManager.regenerateCertificatesOf(productUuid,lazy);
}

Fixed version (ground truth):
@Override public void toExecute(JobExecutionContext arg0) throws JobExecutionException {
  String productId=arg0.getJobDetail().getJobDataMap().getString(PROD_ID);
  boolean lazy=arg0.getJobDetail().getJobDataMap().getBoolean(LAZY_REGEN);
}
Program: 49411
Project: 49411
Buggy source:
/** 
 * Regenerates the Entitlement Certificates for a Product
 * @return a JobDetail object
 * @httpcode 202
 */
@PUT @Path("String_Node_Str") public JobDetail regenerateEntitlementCertificatesForProduct(@PathParam("String_Node_Str") String productId,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") boolean lazyRegen){
  prodAdapter.purgeCache(Arrays.asList(productId));
  JobDataMap map=new JobDataMap();
  map.put(RegenProductEntitlementCertsJob.PROD_UUID,productId);
  map.put(RegenProductEntitlementCertsJob.LAZY_REGEN,lazyRegen);
  JobDetail detail=newJob(RegenProductEntitlementCertsJob.class).withIdentity("String_Node_Str" + Util.generateUUID()).usingJobData(map).build();
  return detail;
}

Fixed version (ground truth):
/** 
 * Regenerates the Entitlement Certificates for a Product
 * @return a JobDetail object
 * @httpcode 202
 */
@PUT @Path("String_Node_Str") public JobDetail regenerateEntitlementCertificatesForProduct(@PathParam("String_Node_Str") String productId,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") boolean lazyRegen){
  prodAdapter.purgeCache(Arrays.asList(productId));
  JobDataMap map=new JobDataMap();
  map.put(RegenProductEntitlementCertsJob.PROD_ID,productId);
  map.put(RegenProductEntitlementCertsJob.LAZY_REGEN,lazyRegen);
  JobDetail detail=newJob(RegenProductEntitlementCertsJob.class).withIdentity("String_Node_Str" + Util.generateUUID()).usingJobData(map).build();
  return detail;
}
Program: 49412
Project: 49412
Buggy source:
@Test public void create(){
  envContent=envContentCurator.lookupByEnvironmentAndContent(e,c.getId());
  assertNotNull(envContent);
  e=envCurator.find(e.getId());
  assertEquals(1,e.getEnvironmentContent().size());
  assertEquals(1,envContentCurator.lookupByContent(c.getId()).size());
}

Fixed version (ground truth):
@Test public void create(){
  envContent=envContentCurator.lookupByEnvironmentAndContent(e,c.getId());
  assertNotNull(envContent);
  e=envCurator.find(e.getId());
  assertEquals(1,e.getEnvironmentContent().size());
  assertEquals(1,envContentCurator.lookupByContent(owner,c.getId()).size());
}
Program: 49413
Project: 49413
Buggy source:
@Test public void testGetProductIdFromContentId(){
  Product p=createTestProduct();
  Content content=new Content(this.owner,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  p.addContent(content);
  contentCurator.create(content);
  productCurator.create(p);
  List<String> contentUuids=new LinkedList<String>();
  contentUuids.add(content.getUuid());
  List<String> productIds=productCurator.getProductsWithContentUuids(contentUuids);
  assertEquals(1,productIds.size());
  assertEquals(p.getUuid(),productIds.get(0));
}

Fixed version (ground truth):
@Test public void testGetProductIdFromContentId(){
  Product p=createTestProduct();
  Content content=new Content(this.owner,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  p.addContent(content);
  contentCurator.create(content);
  productCurator.create(p);
  List<String> contentUuids=new LinkedList<String>();
  contentUuids.add(content.getUuid());
  List<Product> products=productCurator.getProductsWithContent(contentUuids);
  assertEquals(1,products.size());
  assertEquals(p,products.get(0));
}
Program: 49414
Project: 49414
Buggy source:
@Test public void execute() throws Exception {
  CandlepinPoolManager pm=mock(CandlepinPoolManager.class);
  JobExecutionContext jec=mock(JobExecutionContext.class);
  JobDetail detail=mock(JobDetail.class);
  JobDataMap jdm=mock(JobDataMap.class);
  when(jdm.getString(eq("String_Node_Str"))).thenReturn("String_Node_Str");
  when(jdm.getBoolean(eq("String_Node_Str"))).thenReturn(true);
  when(detail.getJobDataMap()).thenReturn(jdm);
  when(jec.getJobDetail()).thenReturn(detail);
  RegenProductEntitlementCertsJob recj=new RegenProductEntitlementCertsJob(pm);
  recj.execute(jec);
  verify(pm).regenerateCertificatesOf(eq("String_Node_Str"),eq(true));
}

Fixed version (ground truth):
@Test public void execute() throws Exception {
  CandlepinPoolManager pm=mock(CandlepinPoolManager.class);
  JobExecutionContext jec=mock(JobExecutionContext.class);
  JobDetail detail=mock(JobDetail.class);
  JobDataMap jdm=mock(JobDataMap.class);
  when(jdm.getString(eq("String_Node_Str"))).thenReturn("String_Node_Str");
  when(jdm.getBoolean(eq("String_Node_Str"))).thenReturn(true);
  when(detail.getJobDataMap()).thenReturn(jdm);
  when(jec.getJobDetail()).thenReturn(detail);
  RegenProductEntitlementCertsJob recj=new RegenProductEntitlementCertsJob(pm);
  recj.execute(jec);
}
Program: 49415
Project: 49415
Buggy source:
@Test public void brandingDidntChange(){
  Subscription s=TestUtil.createSubscription(owner,TestUtil.createProduct(owner));
  Branding b1=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  Branding b2=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  s.getBranding().add(b1);
  s.getBranding().add(b2);
  when(productAdapterMock.getProductById(s.getProduct().getUuid())).thenReturn(s.getProduct());
  Pool p=TestUtil.copyFromSub(s);
  List<Pool> existingPools=Arrays.asList(p);
  List<PoolUpdate> updates=this.poolRules.updatePools(s,existingPools);
  assertEquals(0,updates.size());
}

Fixed version (ground truth):
@Test public void brandingDidntChange(){
  Subscription s=TestUtil.createSubscription(owner,TestUtil.createProduct(owner));
  Branding b1=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  Branding b2=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  s.getBranding().add(b1);
  s.getBranding().add(b2);
  when(productAdapterMock.getProductById(s.getProduct().getOwner(),s.getProduct().getId())).thenReturn(s.getProduct());
  Pool p=TestUtil.copyFromSub(s);
  List<Pool> existingPools=Arrays.asList(p);
  List<PoolUpdate> updates=this.poolRules.updatePools(s,existingPools);
  assertEquals(0,updates.size());
}
Program: 49416
Project: 49416
Buggy source:
@Test public void productIdChangeOnProductPoolAttributeTriggersUpdate(){
  Subscription s=TestUtil.createSubscription(owner,TestUtil.createProduct(owner));
  String testAttributeKey="String_Node_Str";
  s.getProduct().setAttribute(testAttributeKey,"String_Node_Str");
  Pool p=TestUtil.copyFromSub(s);
  p.getProduct().setAttribute(testAttributeKey,"String_Node_Str");
  String expectedProductId="String_Node_Str";
  s.getProduct().setId(expectedProductId);
  when(productAdapterMock.getProductById(s.getProduct().getUuid())).thenReturn(s.getProduct());
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p);
  List<PoolUpdate> updates=this.poolRules.updatePools(s,existingPools);
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  Pool updatedPool=update.getPool();
  assertEquals(s.getProduct(),updatedPool.getProduct());
  assertTrue(updatedPool.getProduct().hasAttribute(testAttributeKey));
}

Fixed version (ground truth):
@Test public void productIdChangeOnProductPoolAttributeTriggersUpdate(){
  Subscription s=TestUtil.createSubscription(owner,TestUtil.createProduct(owner));
  String testAttributeKey="String_Node_Str";
  s.getProduct().setAttribute(testAttributeKey,"String_Node_Str");
  Pool p=TestUtil.copyFromSub(s);
  p.getProduct().setAttribute(testAttributeKey,"String_Node_Str");
  String expectedProductId="String_Node_Str";
  s.getProduct().setId(expectedProductId);
  when(productAdapterMock.getProductById(s.getProduct().getOwner(),s.getProduct().getId())).thenReturn(s.getProduct());
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p);
  List<PoolUpdate> updates=this.poolRules.updatePools(s,existingPools);
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  Pool updatedPool=update.getPool();
  assertEquals(s.getProduct(),updatedPool.getProduct());
  assertTrue(updatedPool.getProduct().hasAttribute(testAttributeKey));
}
Program: 49417
Project: 49417
Buggy source:
private Subscription createVirtLimitSub(String productId,int quantity,int virtLimit){
  Product product=new Product(productId,productId,owner);
  product.setAttribute("String_Node_Str",Integer.toString(virtLimit));
  when(productAdapterMock.getProductById(productId)).thenReturn(product);
  Subscription s=TestUtil.createSubscription(product);
  s.setQuantity(new Long(quantity));
  return s;
}

Fixed version (ground truth):
private Subscription createVirtLimitSub(String productId,int quantity,int virtLimit){
  Product product=new Product(productId,productId,owner);
  product.setAttribute("String_Node_Str",Integer.toString(virtLimit));
  when(productAdapterMock.getProductById(product.getOwner(),product.getId())).thenReturn(product);
  Subscription s=TestUtil.createSubscription(product);
  s.setQuantity(new Long(quantity));
  return s;
}
Program: 49418
Project: 49418
Buggy source:
@Test public void brandingCopiedWhenCreatingPools(){
  Product product=TestUtil.createProduct(owner);
  Subscription sub=TestUtil.createSubscription(owner,product);
  Branding b1=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  Branding b2=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  sub.getBranding().add(b1);
  sub.getBranding().add(b2);
  when(this.productAdapterMock.getProductById(anyString())).thenReturn(product);
  List<Pool> pools=this.poolRules.createPools(sub);
  assertEquals(1,pools.size());
  Pool resultPool=pools.get(0);
  assertEquals(2,resultPool.getBranding().size());
  assertTrue(resultPool.getBranding().contains(b1));
  assertTrue(resultPool.getBranding().contains(b2));
}

Fixed version (ground truth):
@Test public void brandingCopiedWhenCreatingPools(){
  Product product=TestUtil.createProduct(owner);
  Subscription sub=TestUtil.createSubscription(owner,product);
  Branding b1=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  Branding b2=new Branding("String_Node_Str","String_Node_Str","String_Node_Str");
  sub.getBranding().add(b1);
  sub.getBranding().add(b2);
  when(this.productAdapterMock.getProductById(product.getOwner(),product.getId())).thenReturn(product);
  List<Pool> pools=this.poolRules.createPools(sub);
  assertEquals(1,pools.size());
  Pool resultPool=pools.get(0);
  assertEquals(2,resultPool.getBranding().size());
  assertTrue(resultPool.getBranding().contains(b1));
  assertTrue(resultPool.getBranding().contains(b2));
}
Program: 49419
Project: 49419
Buggy source:
@Test public void subProvidedProductsCopiedOntoPoolWhenCreatingNewPool(){
  Product product=TestUtil.createProduct(owner);
  Product subProduct=TestUtil.createProduct(owner);
  Product subProvidedProduct=TestUtil.createProduct(owner);
  Subscription sub=TestUtil.createSubscription(owner,product);
  sub.setDerivedProduct(subProduct);
  Set<Product> subProvided=new HashSet<Product>();
  subProvided.add(subProvidedProduct);
  sub.setDerivedProvidedProducts(subProvided);
  when(this.productAdapterMock.getProductById(anyString())).thenReturn(product);
  when(this.productAdapterMock.getProductById(anyString())).thenReturn(subProduct);
  List<Pool> pools=this.poolRules.createPools(sub);
  assertEquals(1,pools.size());
  Pool resultPool=pools.get(0);
  assertEquals(1,resultPool.getDerivedProvidedProducts().size());
}

Fixed version (ground truth):
@Test public void subProvidedProductsCopiedOntoPoolWhenCreatingNewPool(){
  Product product=TestUtil.createProduct(owner);
  Product subProduct=TestUtil.createProduct(owner);
  Product subProvidedProduct=TestUtil.createProduct(owner);
  Subscription sub=TestUtil.createSubscription(owner,product);
  sub.setDerivedProduct(subProduct);
  Set<Product> subProvided=new HashSet<Product>();
  subProvided.add(subProvidedProduct);
  sub.setDerivedProvidedProducts(subProvided);
  when(this.productAdapterMock.getProductById(product.getOwner(),product.getId())).thenReturn(product);
  when(this.productAdapterMock.getProductById(subProduct.getOwner(),subProduct.getId())).thenReturn(subProduct);
  List<Pool> pools=this.poolRules.createPools(sub);
  assertEquals(1,pools.size());
  Pool resultPool=pools.get(0);
  assertEquals(1,resultPool.getDerivedProvidedProducts().size());
}
Program: 49420
Project: 49420
Buggy source:
@Test public void productAttributesCopiedOntoPoolWhenCreatingNewPool(){
  Product product=TestUtil.createProduct(owner);
  Subscription sub=TestUtil.createSubscription(owner,product);
  String testAttributeKey="String_Node_Str";
  String expectedAttributeValue="String_Node_Str";
  sub.getProduct().setAttribute(testAttributeKey,expectedAttributeValue);
  when(this.productAdapterMock.getProductById(anyString())).thenReturn(product);
  List<Pool> pools=this.poolRules.createPools(sub);
  assertEquals(1,pools.size());
  Pool resultPool=pools.get(0);
  assertNotNull(resultPool.getProduct());
  assertTrue(resultPool.getProduct().hasAttribute(testAttributeKey));
  assertEquals(expectedAttributeValue,resultPool.getProduct().getAttributeValue(testAttributeKey));
}

Fixed version (ground truth):
@Test public void productAttributesCopiedOntoPoolWhenCreatingNewPool(){
  Product product=TestUtil.createProduct(owner);
  Subscription sub=TestUtil.createSubscription(owner,product);
  String testAttributeKey="String_Node_Str";
  String expectedAttributeValue="String_Node_Str";
  sub.getProduct().setAttribute(testAttributeKey,expectedAttributeValue);
  when(this.productAdapterMock.getProductById(product.getOwner(),product.getId())).thenReturn(product);
  List<Pool> pools=this.poolRules.createPools(sub);
  assertEquals(1,pools.size());
  Pool resultPool=pools.get(0);
  assertNotNull(resultPool.getProduct());
  assertTrue(resultPool.getProduct().hasAttribute(testAttributeKey));
  assertEquals(expectedAttributeValue,resultPool.getProduct().getAttributeValue(testAttributeKey));
}