nus-yam/ex-repair huggingface dataset:
Program: 49313
Project: 49313
Buggy source:
@Test public void hostedInstanceBasedUpdatePool(){
  Subscription s=createInstanceBasedSub("String_Node_Str",100,2,false);
  Pool p=TestUtil.copyFromSub(s);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(1,pools.size());
  Pool pool=pools.get(0);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  p.setQuantity(new Long(200));
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(pool);
  List<PoolUpdate> updates=poolRules.updatePools(p,existingPools,TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getQuantityChanged());
  assertEquals(new Long(800),update.getPool().getQuantity());
}

Fixed version (ground truth):
@Test public void hostedInstanceBasedUpdatePool(){
  Subscription s=createInstanceBasedSub("String_Node_Str",100,2,false);
  Pool p=TestUtil.copyFromSub(s);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(1,pools.size());
  Pool pool=pools.get(0);
  p=TestUtil.copyFromSub(s);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  p.setQuantity(new Long(200));
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(pool);
  List<PoolUpdate> updates=poolRules.updatePools(p,existingPools,p.getQuantity(),TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getQuantityChanged());
  assertEquals(new Long(800),update.getPool().getQuantity());
}
Program: 49314
Project: 49314
Buggy source:
@Test public void standaloneInstanceBasedUpdatePool(){
  Subscription s=createInstanceBasedSub("String_Node_Str",100,2,true);
  Pool masterPool=TestUtil.copyFromSub(s);
  List<Pool> pools=poolRules.createAndEnrichPools(masterPool,new LinkedList<Pool>());
  assertEquals(1,pools.size());
  Pool pool=pools.get(0);
  masterPool=TestUtil.copyFromSub(s);
  masterPool.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  masterPool.setQuantity(new Long(200));
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(pool);
  List<PoolUpdate> updates=poolRules.updatePools(masterPool,existingPools,TestUtil.stubChangedProducts(masterPool.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getQuantityChanged());
  assertEquals(new Long(200),update.getPool().getQuantity());
}

Fixed version (ground truth):
@Test public void standaloneInstanceBasedUpdatePool(){
  Subscription s=createInstanceBasedSub("String_Node_Str",100,2,true);
  Pool masterPool=TestUtil.copyFromSub(s);
  List<Pool> pools=poolRules.createAndEnrichPools(masterPool,new LinkedList<Pool>());
  assertEquals(1,pools.size());
  Pool pool=pools.get(0);
  masterPool=TestUtil.copyFromSub(s);
  masterPool.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  masterPool.setQuantity(new Long(200));
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(pool);
  List<PoolUpdate> updates=poolRules.updatePools(masterPool,existingPools,masterPool.getQuantity(),TestUtil.stubChangedProducts(masterPool.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getQuantityChanged());
  assertEquals(new Long(200),update.getPool().getQuantity());
}
Program: 49315
Project: 49315
Buggy source:
@Test public void brandingDidntChange(){
  Pool p=TestUtil.createPool(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");
  p.getBranding().add(b1);
  p.getBranding().add(b2);
  when(productAdapterMock.getProductById(p.getProduct().getOwner(),p.getProduct().getId())).thenReturn(p.getProduct());
  Pool p1=TestUtil.clone(p);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(0,updates.size());
}

Fixed version (ground truth):
@Test public void brandingDidntChange(){
  Pool p=TestUtil.createPool(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");
  p.getBranding().add(b1);
  p.getBranding().add(b2);
  when(productAdapterMock.getProductById(p.getProduct().getOwner(),p.getProduct().getId())).thenReturn(p.getProduct());
  Pool p1=TestUtil.clone(p);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(0,updates.size());
}
Program: 49316
Project: 49316
Buggy source:
@Test public void hostedVirtLimitSubUpdatesUnlimitedBonusVirtOnlyPool(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  Pool virtBonusPool=pools.get(1);
  assertEquals(new Long(-1),virtBonusPool.getQuantity());
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(2,updates.size());
  PoolUpdate virtUpdate=updates.get(1);
  assertEquals(new Long(100),virtUpdate.getPool().getQuantity());
}

Fixed version (ground truth):
@Test public void hostedVirtLimitSubUpdatesUnlimitedBonusVirtOnlyPool(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  Pool virtBonusPool=pools.get(1);
  assertEquals(new Long(-1),virtBonusPool.getQuantity());
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,p.getQuantity(),TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(2,updates.size());
  PoolUpdate virtUpdate=updates.get(1);
  assertEquals(new Long(100),virtUpdate.getPool().getQuantity());
}
Program: 49317
Project: 49317
Buggy source:
@Test public void updateVirtOnlyNoVirtLimit(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setQuantity(10L);
  Pool p1=TestUtil.clone(p);
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.setQuantity(20L);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertTrue(update.getQuantityChanged());
  assertEquals(Long.valueOf(10),update.getPool().getQuantity());
}

Fixed version (ground truth):
@Test public void updateVirtOnlyNoVirtLimit(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setQuantity(10L);
  Pool p1=TestUtil.clone(p);
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.setQuantity(20L);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertTrue(update.getQuantityChanged());
  assertEquals(Long.valueOf(10),update.getPool().getQuantity());
}
Program: 49318
Project: 49318
Buggy source:
@Test public void standaloneVirtLimitSubUpdate(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  Pool physicalPool=pools.get(0);
  assertEquals(0,physicalPool.getAttributes().size());
  p=createVirtLimitPool("String_Node_Str",10,10);
  p.setQuantity(50L);
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,new HashSet<Product>());
  assertEquals(2,updates.size());
  physicalPool=updates.get(0).getPool();
  Pool unmappedPool=updates.get(1).getPool();
  assertEquals(new Long(50),physicalPool.getQuantity());
  assertEquals(0,physicalPool.getAttributes().size());
}

Fixed version (ground truth):
@Test public void standaloneVirtLimitSubUpdate(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  Pool physicalPool=pools.get(0);
  assertEquals(0,physicalPool.getAttributes().size());
  p=createVirtLimitPool("String_Node_Str",10,10);
  p.setQuantity(50L);
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,p.getQuantity(),new HashSet<Product>());
  assertEquals(2,updates.size());
  physicalPool=updates.get(0).getPool();
  Pool unmappedPool=updates.get(1).getPool();
  assertEquals(new Long(50),physicalPool.getQuantity());
  assertEquals(0,physicalPool.getAttributes().size());
}
Program: 49319
Project: 49319
Buggy source:
@Test public void productNameChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  p1.getProduct().setName("String_Node_Str");
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
  assertEquals(p.getProduct().getName(),update.getPool().getProductName());
}

Fixed version (ground truth):
@Test public void productNameChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  p1.getProduct().setName("String_Node_Str");
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
  assertEquals(p.getProduct().getName(),update.getPool().getProductName());
}
Program: 49320
Project: 49320
Buggy source:
@Test public void quantityChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertTrue(update.getQuantityChanged());
  assertEquals(p.getQuantity(),update.getPool().getQuantity());
}

Fixed version (ground truth):
@Test public void quantityChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertTrue(update.getQuantityChanged());
  assertEquals(p.getQuantity(),update.getPool().getQuantity());
}
Program: 49321
Project: 49321
Buggy source:
@Test public void brandingChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  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");
  p.getBranding().add(b1);
  p.getBranding().add(b2);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
  assertTrue(update.getBrandingChanged());
  assertTrue(update.changed());
  assertEquals(2,update.getPool().getBranding().size());
  assertTrue(update.getPool().getBranding().contains(b1));
  assertTrue(update.getPool().getBranding().contains(b2));
}

Fixed version (ground truth):
@Test public void brandingChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  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");
  p.getBranding().add(b1);
  p.getBranding().add(b2);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
  assertTrue(update.getBrandingChanged());
  assertTrue(update.changed());
  assertEquals(2,update.getPool().getBranding().size());
  assertTrue(update.getPool().getBranding().contains(b1));
  assertTrue(update.getPool().getBranding().contains(b2));
}
Program: 49322
Project: 49322
Buggy source:
@Test public void updatePoolSubProvidedProductsChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Product subProd=TestUtil.createProduct(owner);
  p.setDerivedProduct(subProd);
  Product product1=TestUtil.createProduct(owner);
  Product product2=TestUtil.createProduct(owner);
  Product product3=TestUtil.createProduct(owner);
  p.getDerivedProvidedProducts().add(product1);
  p.getDerivedProvidedProducts().add(product2);
  Pool p1=TestUtil.clone(p);
  p1.getProvidedProducts().clear();
  p1.getProvidedProducts().add(product3);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  assertEquals(2,updates.get(0).getPool().getDerivedProvidedProducts().size());
}

Fixed version (ground truth):
@Test public void updatePoolSubProvidedProductsChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Product subProd=TestUtil.createProduct(owner);
  p.setDerivedProduct(subProd);
  Product product1=TestUtil.createProduct(owner);
  Product product2=TestUtil.createProduct(owner);
  Product product3=TestUtil.createProduct(owner);
  p.getDerivedProvidedProducts().add(product1);
  p.getDerivedProvidedProducts().add(product2);
  Pool p1=TestUtil.clone(p);
  p1.getProvidedProducts().clear();
  p1.getProvidedProducts().add(product3);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  assertEquals(2,updates.get(0).getPool().getDerivedProvidedProducts().size());
}
Program: 49323
Project: 49323
Buggy source:
@Test public void standaloneVirtSubPoolUpdateNoChanges(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  Entitlement ent=mock(Entitlement.class);
  when(ent.getQuantity()).thenReturn(1);
  Pool consumerSpecificPool=TestUtil.clone(p);
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setQuantity(10L);
  consumerSpecificPool.setSourceEntitlement(ent);
  pools.add(consumerSpecificPool);
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,new HashSet<Product>());
  assertEquals(0,updates.size());
}

Fixed version (ground truth):
@Test public void standaloneVirtSubPoolUpdateNoChanges(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  Entitlement ent=mock(Entitlement.class);
  when(ent.getQuantity()).thenReturn(1);
  Pool consumerSpecificPool=TestUtil.clone(p);
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setQuantity(10L);
  consumerSpecificPool.setSourceEntitlement(ent);
  pools.add(consumerSpecificPool);
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,p.getQuantity(),new HashSet<Product>());
  assertEquals(0,updates.size());
}
Program: 49324
Project: 49324
Buggy source:
@Test public void providedProductsChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Product product1=TestUtil.createProduct(owner);
  Product product2=TestUtil.createProduct(owner);
  Product product3=TestUtil.createProduct(owner);
  p.getProvidedProducts().add(product1);
  p.getProvidedProducts().add(product2);
  Pool p1=TestUtil.clone(p);
  p1.getProvidedProducts().clear();
  p1.getProvidedProducts().add(product3);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
}

Fixed version (ground truth):
@Test public void providedProductsChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Product product1=TestUtil.createProduct(owner);
  Product product2=TestUtil.createProduct(owner);
  Product product3=TestUtil.createProduct(owner);
  p.getProvidedProducts().add(product1);
  p.getProvidedProducts().add(product2);
  Pool p1=TestUtil.clone(p);
  p1.getProvidedProducts().clear();
  p1.getProvidedProducts().add(product3);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
}
Program: 49325
Project: 49325
Buggy source:
@Test public void accountNumberChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setAccountNumber("String_Node_Str");
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  p1.setAccountNumber("String_Node_Str");
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getOrderChanged());
  assertEquals("String_Node_Str",update.getPool().getAccountNumber());
}

Fixed version (ground truth):
@Test public void accountNumberChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setAccountNumber("String_Node_Str");
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  p1.setAccountNumber("String_Node_Str");
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getOrderChanged());
  assertEquals("String_Node_Str",update.getPool().getAccountNumber());
}
Program: 49326
Project: 49326
Buggy source:
@Test public void orderNumberChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setOrderNumber("String_Node_Str");
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  p1.setOrderNumber("String_Node_Str");
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getOrderChanged());
  assertEquals("String_Node_Str",update.getPool().getOrderNumber());
}

Fixed version (ground truth):
@Test public void orderNumberChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setOrderNumber("String_Node_Str");
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  p1.setOrderNumber("String_Node_Str");
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getOrderChanged());
  assertEquals("String_Node_Str",update.getPool().getOrderNumber());
}
Program: 49327
Project: 49327
Buggy source:
@Test public void standaloneVirtSubPoolUpdateVirtLimitChanged(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  p.setQuantity(new Long(20));
  Entitlement ent=mock(Entitlement.class);
  when(ent.getQuantity()).thenReturn(4);
  Pool consumerSpecificPool=TestUtil.clone(p);
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setQuantity(10L);
  consumerSpecificPool.setSourceEntitlement(ent);
  pools.add(consumerSpecificPool);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(3,updates.size());
  Pool regular=updates.get(0).getPool();
  Pool unmappedSubPool=updates.get(1).getPool();
  Pool subPool=updates.get(2).getPool();
  assertEquals("String_Node_Str",regular.getProduct().getAttributeValue("String_Node_Str"));
  assertEquals(new Long(40),subPool.getQuantity());
  assertEquals(new Long(800),unmappedSubPool.getQuantity());
}

Fixed version (ground truth):
@Test public void standaloneVirtSubPoolUpdateVirtLimitChanged(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  p.setQuantity(new Long(20));
  Entitlement ent=mock(Entitlement.class);
  when(ent.getQuantity()).thenReturn(4);
  Pool consumerSpecificPool=TestUtil.clone(p);
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setQuantity(10L);
  consumerSpecificPool.setSourceEntitlement(ent);
  pools.add(consumerSpecificPool);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,p.getQuantity(),TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(3,updates.size());
  Pool regular=updates.get(0).getPool();
  Pool unmappedSubPool=updates.get(1).getPool();
  Pool subPool=updates.get(2).getPool();
  assertEquals("String_Node_Str",regular.getProduct().getAttributeValue("String_Node_Str"));
  assertEquals(new Long(40),subPool.getQuantity());
  assertEquals(new Long(800),unmappedSubPool.getQuantity());
}
Program: 49328
Project: 49328
Buggy source:
@Test public void virtOnlyQuantityChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.getProduct().addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  p.setQuantity(10L);
  when(productAdapterMock.getProductById(p.getProduct().getOwner(),p.getProduct().getId())).thenReturn(p.getProduct());
  Pool p1=TestUtil.clone(p);
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.setQuantity(40L);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,null);
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getProductAttributesChanged());
  assertTrue(update.getQuantityChanged());
  assertEquals(Long.valueOf(50),update.getPool().getQuantity());
}

Fixed version (ground truth):
@Test public void virtOnlyQuantityChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.getProduct().addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  p.setQuantity(10L);
  when(productAdapterMock.getProductById(p.getProduct().getOwner(),p.getProduct().getId())).thenReturn(p.getProduct());
  Pool p1=TestUtil.clone(p);
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.setQuantity(40L);
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),null);
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertFalse(update.getDatesChanged());
  assertFalse(update.getProductAttributesChanged());
  assertTrue(update.getQuantityChanged());
  assertEquals(Long.valueOf(50),update.getPool().getQuantity());
}
Program: 49329
Project: 49329
Buggy source:
@Test public void hostedVirtLimitRemoved(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  p.setProduct(TestUtil.createProduct(p.getProduct().getId(),p.getProduct().getName(),owner));
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(2,updates.size());
  PoolUpdate baseUpdate=updates.get(0);
  assertEquals(new Long(10),baseUpdate.getPool().getQuantity());
  assertFalse(baseUpdate.getPool().isMarkedForDelete());
  PoolUpdate virtUpdate=updates.get(1);
  assertEquals(new Long(0),virtUpdate.getPool().getQuantity());
  assertTrue(virtUpdate.getPool().isMarkedForDelete());
}

Fixed version (ground truth):
@Test public void hostedVirtLimitRemoved(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=createVirtLimitPool("String_Node_Str",10,10);
  p.getProduct().setAttribute("String_Node_Str","String_Node_Str");
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(2,pools.size());
  p.setProduct(TestUtil.createProduct(p.getProduct().getId(),p.getProduct().getName(),owner));
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,p.getQuantity(),TestUtil.stubChangedProducts(p.getProduct()));
  assertEquals(2,updates.size());
  PoolUpdate baseUpdate=updates.get(0);
  assertEquals(new Long(10),baseUpdate.getPool().getQuantity());
  assertFalse(baseUpdate.getPool().isMarkedForDelete());
  PoolUpdate virtUpdate=updates.get(1);
  assertEquals(new Long(0),virtUpdate.getPool().getQuantity());
  assertTrue(virtUpdate.getPool().isMarkedForDelete());
}
Program: 49330
Project: 49330
Buggy source:
@Test public void dontUpdateVirtOnlyNoVirtLimit(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setQuantity(10L);
  when(productAdapterMock.getProductById(p.getProduct().getOwner(),p.getProduct().getId())).thenReturn(p.getProduct());
  Pool p1=TestUtil.clone(p);
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.setQuantity(10L);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(0,updates.size());
}

Fixed version (ground truth):
@Test public void dontUpdateVirtOnlyNoVirtLimit(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setQuantity(10L);
  when(productAdapterMock.getProductById(p.getProduct().getOwner(),p.getProduct().getId())).thenReturn(p.getProduct());
  Pool p1=TestUtil.clone(p);
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.addAttribute(new PoolAttribute("String_Node_Str","String_Node_Str"));
  p1.setQuantity(10L);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(0,updates.size());
}
Program: 49331
Project: 49331
Buggy source:
@Test public void hostedVirtOnlySubUpdate(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtOnlyPool("String_Node_Str",10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(1,pools.size());
  p=createVirtOnlyPool("String_Node_Str",20);
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,new HashSet<Product>());
  assertEquals(1,updates.size());
  Pool updated=updates.get(0).getPool();
  assertEquals(new Long(20),updated.getQuantity());
}

Fixed version (ground truth):
@Test public void hostedVirtOnlySubUpdate(){
  when(configMock.getBoolean(ConfigProperties.STANDALONE)).thenReturn(true);
  Pool p=createVirtOnlyPool("String_Node_Str",10);
  List<Pool> pools=poolRules.createAndEnrichPools(p,new LinkedList<Pool>());
  assertEquals(1,pools.size());
  p=createVirtOnlyPool("String_Node_Str",20);
  List<PoolUpdate> updates=poolRules.updatePools(p,pools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  Pool updated=updates.get(0).getPool();
  assertEquals(new Long(20),updated.getQuantity());
}
Program: 49332
Project: 49332
Buggy source:
@Test public void contractNumberChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setContractNumber("String_Node_Str");
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  p1.setContractNumber("String_Node_Str");
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getOrderChanged());
  assertEquals("String_Node_Str",update.getPool().getContractNumber());
}

Fixed version (ground truth):
@Test public void contractNumberChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  p.setContractNumber("String_Node_Str");
  Pool p1=TestUtil.clone(p);
  p1.setQuantity(2000L);
  p1.setContractNumber("String_Node_Str");
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getOrderChanged());
  assertEquals("String_Node_Str",update.getPool().getContractNumber());
}
Program: 49333
Project: 49333
Buggy source:
@Test public void datesNameChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  p1.setEndDate(new Date());
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertTrue(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
  assertEquals(p.getEndDate(),update.getPool().getEndDate());
}

Fixed version (ground truth):
@Test public void datesNameChanged(){
  Pool p=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Pool p1=TestUtil.clone(p);
  p1.setEndDate(new Date());
  List<Pool> existingPools=Arrays.asList(p1);
  List<PoolUpdate> updates=this.poolRules.updatePools(p,existingPools,p.getQuantity(),new HashSet<Product>());
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertFalse(update.getProductsChanged());
  assertTrue(update.getDatesChanged());
  assertFalse(update.getQuantityChanged());
  assertEquals(p.getEndDate(),update.getPool().getEndDate());
}
Program: 49334
Project: 49334
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + (owner != null ? owner.getKey() : null) + "String_Node_Str"+ id+ "String_Node_Str"+ name+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  String ownerKey=(owner != null ? owner.getKey() : null);
  return "String_Node_Str" + ownerKey + "String_Node_Str"+ id+ "String_Node_Str"+ name+ "String_Node_Str";
}
Program: 49335
Project: 49335
Buggy source:
@Test public void testCreateUeberCertificateRegenerate(){
  Principal principal=setupPrincipal(owner,Access.ALL);
  Owner owner=TestUtil.createOwner();
  Consumer consumer=TestUtil.createConsumer(owner);
  Entitlement ent=mock(Entitlement.class);
  List<Entitlement> entList=Arrays.asList(ent);
  EntitlementCertificate entCert=mock(EntitlementCertificate.class);
  List<EntitlementCertificate> ecList=Arrays.asList(entCert);
  OwnerCurator oc=mock(OwnerCurator.class);
  ConsumerCurator cc=mock(ConsumerCurator.class);
  EntitlementCurator ec=mock(EntitlementCurator.class);
  CandlepinPoolManager cpm=mock(CandlepinPoolManager.class);
  EntitlementCertificateCurator ecc=mock(EntitlementCertificateCurator.class);
  UeberCertificateGenerator ucg=mock(UeberCertificateGenerator.class);
  OwnerResource resource=new OwnerResource(oc,null,cc,null,i18n,null,null,null,null,null,cpm,null,null,null,null,null,ecc,ec,ucg,null,null,null,null,null,null,null,null);
  when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(owner);
  when(cc.findByName(eq(owner),eq(Consumer.UEBER_CERT_CONSUMER))).thenReturn(consumer);
  when(ec.listByConsumer(eq(consumer))).thenReturn(entList);
  when(ecc.listForConsumer(eq(consumer))).thenReturn(ecList);
  EntitlementCertificate result=resource.createUeberCertificate(principal,"String_Node_Str");
  assertEquals(entCert,result);
}

Fixed version (ground truth):
@Test public void testCreateUeberCertificateRegenerate(){
  Principal principal=setupPrincipal(owner,Access.ALL);
  Owner owner=TestUtil.createOwner();
  Consumer consumer=TestUtil.createConsumer(owner);
  Entitlement ent=mock(Entitlement.class);
  List<Entitlement> entList=Arrays.asList(ent);
  EntitlementCertificate entCert=mock(EntitlementCertificate.class);
  List<EntitlementCertificate> ecList=Arrays.asList(entCert);
  OwnerCurator oc=mock(OwnerCurator.class);
  ConsumerCurator cc=mock(ConsumerCurator.class);
  EntitlementCurator ec=mock(EntitlementCurator.class);
  CandlepinPoolManager cpm=mock(CandlepinPoolManager.class);
  EntitlementCertificateCurator ecc=mock(EntitlementCertificateCurator.class);
  UeberCertificateGenerator ucg=mock(UeberCertificateGenerator.class);
  OwnerResource resource=new OwnerResource(oc,null,cc,null,i18n,null,null,null,null,null,cpm,null,null,null,null,null,ecc,ec,ucg,null,null,null,null,null,null,null,null,null);
  when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(owner);
  when(cc.findByName(eq(owner),eq(Consumer.UEBER_CERT_CONSUMER))).thenReturn(consumer);
  when(ec.listByConsumer(eq(consumer))).thenReturn(entList);
  when(ecc.listForConsumer(eq(consumer))).thenReturn(ecList);
  EntitlementCertificate result=resource.createUeberCertificate(principal,"String_Node_Str");
  assertEquals(entCert,result);
}
Program: 49336
Project: 49336
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,i18n,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());
}

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,i18n,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,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: 49337
Project: 49337
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,i18n,es,null,null,null,importer,null,null,null,importRecordCurator,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());
}

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,i18n,es,null,null,null,importer,null,null,null,importRecordCurator,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,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: 49338
Project: 49338
Buggy source:
@Test public void testCreateUeberCertificateFromScratch(){
  Principal principal=setupPrincipal(owner,Access.ALL);
  Owner owner=TestUtil.createOwner();
  Consumer consumer=TestUtil.createConsumer(owner);
  EntitlementCertificate entCert=mock(EntitlementCertificate.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  ConsumerCurator cc=mock(ConsumerCurator.class);
  EntitlementCurator ec=mock(EntitlementCurator.class);
  CandlepinPoolManager cpm=mock(CandlepinPoolManager.class);
  EntitlementCertificateCurator ecc=mock(EntitlementCertificateCurator.class);
  UeberCertificateGenerator ucg=mock(UeberCertificateGenerator.class);
  OwnerResource resource=new OwnerResource(oc,null,cc,null,i18n,null,null,null,null,null,cpm,null,null,null,null,null,ecc,ec,ucg,null,null,null,null,null,null,null,null);
  try {
    when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(owner);
    when(cc.findByName(eq(owner),eq(Consumer.UEBER_CERT_CONSUMER))).thenReturn(null);
    when(ucg.generate(eq(owner),eq(principal))).thenReturn(entCert);
  }
 catch (  EntitlementRefusedException ere) {
  }
  EntitlementCertificate result=resource.createUeberCertificate(principal,"String_Node_Str");
  assertEquals(entCert,result);
}

Fixed version (ground truth):
@Test public void testCreateUeberCertificateFromScratch(){
  Principal principal=setupPrincipal(owner,Access.ALL);
  Owner owner=TestUtil.createOwner();
  Consumer consumer=TestUtil.createConsumer(owner);
  EntitlementCertificate entCert=mock(EntitlementCertificate.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  ConsumerCurator cc=mock(ConsumerCurator.class);
  EntitlementCurator ec=mock(EntitlementCurator.class);
  CandlepinPoolManager cpm=mock(CandlepinPoolManager.class);
  EntitlementCertificateCurator ecc=mock(EntitlementCertificateCurator.class);
  UeberCertificateGenerator ucg=mock(UeberCertificateGenerator.class);
  OwnerResource resource=new OwnerResource(oc,null,cc,null,i18n,null,null,null,null,null,cpm,null,null,null,null,null,ecc,ec,ucg,null,null,null,null,null,null,null,null,null);
  try {
    when(oc.lookupByKey(eq("String_Node_Str"))).thenReturn(owner);
    when(cc.findByName(eq(owner),eq(Consumer.UEBER_CERT_CONSUMER))).thenReturn(null);
    when(ucg.generate(eq(owner),eq(principal))).thenReturn(entCert);
  }
 catch (  EntitlementRefusedException ere) {
  }
  EntitlementCertificate result=resource.createUeberCertificate(principal,"String_Node_Str");
  assertEquals(entCert,result);
}
Program: 49339
Project: 49339
Buggy source:
@Test public void getAllEntitlementsForOwner(){
  PageRequest req=new PageRequest();
  req.setPage(1);
  req.setPerPage(10);
  Owner owner=TestUtil.createOwner();
  Consumer consumer=TestUtil.createConsumer(owner);
  Pool pool=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Entitlement e=TestUtil.createEntitlement(owner,consumer,pool,null);
  e.setId("String_Node_Str");
  List<Entitlement> entitlements=new ArrayList<Entitlement>();
  entitlements.add(e);
  Page<List<Entitlement>> page=new Page<List<Entitlement>>();
  page.setPageData(entitlements);
  OwnerCurator oc=mock(OwnerCurator.class);
  EntitlementCurator ec=mock(EntitlementCurator.class);
  OwnerResource ownerres=new OwnerResource(oc,null,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,ec,null,null,null,null,null,null,null,null,null);
  when(oc.lookupByKey(owner.getKey())).thenReturn(owner);
  when(ec.listByOwner(isA(Owner.class),anyString(),isA(EntitlementFilterBuilder.class),isA(PageRequest.class))).thenReturn(page);
  List<Entitlement> result=ownerres.ownerEntitlements(owner.getKey(),null,null,null,req);
  assertEquals(1,result.size());
  assertEquals("String_Node_Str",result.get(0).getId());
}

Fixed version (ground truth):
@Test public void getAllEntitlementsForOwner(){
  PageRequest req=new PageRequest();
  req.setPage(1);
  req.setPerPage(10);
  Owner owner=TestUtil.createOwner();
  Consumer consumer=TestUtil.createConsumer(owner);
  Pool pool=TestUtil.createPool(owner,TestUtil.createProduct(owner));
  Entitlement e=TestUtil.createEntitlement(owner,consumer,pool,null);
  e.setId("String_Node_Str");
  List<Entitlement> entitlements=new ArrayList<Entitlement>();
  entitlements.add(e);
  Page<List<Entitlement>> page=new Page<List<Entitlement>>();
  page.setPageData(entitlements);
  OwnerCurator oc=mock(OwnerCurator.class);
  EntitlementCurator ec=mock(EntitlementCurator.class);
  OwnerResource ownerres=new OwnerResource(oc,null,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,ec,null,null,null,null,null,null,null,null,null,null);
  when(oc.lookupByKey(owner.getKey())).thenReturn(owner);
  when(ec.listByOwner(isA(Owner.class),anyString(),isA(EntitlementFilterBuilder.class),isA(PageRequest.class))).thenReturn(page);
  List<Entitlement> result=ownerres.ownerEntitlements(owner.getKey(),null,null,null,req);
  assertEquals(1,result.size());
  assertEquals("String_Node_Str",result.get(0).getId());
}
Program: 49340
Project: 49340
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,akc,null,null,i18n,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);
}

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,akc,null,null,i18n,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,contentOverrideValidator,serviceLevelValidator,null,null,null,null,null);
  or.createActivationKey("String_Node_Str",ak);
}