nus-yam/ex-repair huggingface dataset:
Program: 49276
Project: 49276
Buggy source:
private void addProductContentToMap(Map<String,ContentData> contentMap,ProductData product){
  if (product == null) {
    return;
  }
  Map<String,ContentData> mapped=new HashMap<String,ContentData>();
  List<ProductContentData> duplicates=new LinkedList<ProductContentData>();
  for (  ProductContentData pcd : product.getProductContent()) {
    ContentData content=pcd.getContent();
    if (mapped.containsKey(content.getId())) {
      log.warn("String_Node_Str" + "String_Node_Str",product,content,mapped.get(content.getId()));
      duplicates.add(pcd);
      continue;
    }
    mapped.put(content.getId(),content);
    ContentData existing=contentMap.get(content.getId());
    if (existing != null && !content.equals(existing)) {
      log.warn("String_Node_Str" + "String_Node_Str",content.getId(),existing,content);
    }
    contentMap.put(content.getId(),content);
  }
  if (duplicates.size() > 0) {
    log.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
private void addProductContentToMap(Map<String,ContentData> contentMap,ProductData product){
  if (product == null) {
    return;
  }
  Map<String,ContentData> mapped=new HashMap<String,ContentData>();
  List<ProductContentData> duplicates=new LinkedList<ProductContentData>();
  if (product.getProductContent() != null) {
    for (    ProductContentData pcd : product.getProductContent()) {
      ContentData content=pcd.getContent();
      if (mapped.containsKey(content.getId())) {
        log.warn("String_Node_Str" + "String_Node_Str",product,content,mapped.get(content.getId()));
        duplicates.add(pcd);
        continue;
      }
      mapped.put(content.getId(),content);
      ContentData existing=contentMap.get(content.getId());
      if (existing != null && !content.equals(existing)) {
        log.warn("String_Node_Str" + "String_Node_Str",content.getId(),existing,content);
      }
      contentMap.put(content.getId(),content);
    }
  }
  if (duplicates.size() > 0) {
    log.debug("String_Node_Str");
  }
}
Program: 49277
Project: 49277
Buggy source:
/** 
 * Creates a new Content for the given owner, potentially using a different version than the entity provided if a matching entity has already been registered for another owner.
 * @param entity A Content instance representing the content to create
 * @param owner The owner for which to create the content
 * @throws IllegalStateException if this method is called with an entity that already exists in the backing database for the given owner
 * @throws NullPointerException if entity or owner is null
 * @return a new Content instance representing the specified content for the given owner
 */
@Transactional public Content createContent(Content entity,Owner owner){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (owner == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  log.debug("String_Node_Str",entity,owner);
  Content existing=this.contentCurator.lookupById(owner,entity.getId());
  if (existing != null) {
    throw new IllegalStateException("String_Node_Str");
  }
  List<Content> alternateVersions=this.contentCurator.getContentByVersion(entity.getId(),entity.hashCode()).list();
  for (  Content alt : alternateVersions) {
    if (alt.equals(entity)) {
      this.ownerContentCurator.mapContentToOwner(alt,owner);
      return alt;
    }
  }
  entity=this.contentCurator.create(entity);
  this.ownerContentCurator.mapContentToOwner(entity,owner);
  return entity;
}

Fixed version (ground truth):
/** 
 * Creates a new Content for the given owner, potentially using a different version than the entity provided if a matching entity has already been registered for another owner.
 * @param entity A Content instance representing the content to create
 * @param owner The owner for which to create the content
 * @throws IllegalStateException if this method is called with an entity that already exists in the backing database for the given owner
 * @throws NullPointerException if entity or owner is null
 * @return a new Content instance representing the specified content for the given owner
 */
@Transactional public Content createContent(Content entity,Owner owner){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (owner == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  log.debug("String_Node_Str",entity,owner);
  Content existing=this.ownerContentCurator.getContentById(owner,entity.getId());
  if (existing != null) {
    throw new IllegalStateException("String_Node_Str");
  }
  List<Content> alternateVersions=this.contentCurator.getContentByVersion(entity.getId(),entity.hashCode()).list();
  log.debug("String_Node_Str",alternateVersions.size());
  for (  Content alt : alternateVersions) {
    if (alt.equals(entity)) {
      this.ownerContentCurator.mapContentToOwner(alt,owner);
      return alt;
    }
  }
  entity=this.contentCurator.create(entity);
  this.ownerContentCurator.mapContentToOwner(entity,owner);
  return entity;
}
Program: 49279
Project: 49279
Buggy source:
/** 
 * Regenerates the entitlement certificates for all pools using any of the the specified product(s), effective for the all owners using them.
 * @param products A collection of products for which to regenerate affected certificates
 * @param lazy Whether or not to generate the certificate immediately, or mark it dirty and allow it to be regenerated on-demand
 */
@Transactional public void regenerateCertificatesOf(Collection<Product> products,boolean lazy){
  Set<Owner> owners=new HashSet<Owner>();
  for (  Product product : products) {
    throw new RuntimeException("String_Node_Str");
  }
  this.regenerateCertificatesOf(owners,products,lazy);
}

Fixed version (ground truth):
/** 
 * Regenerates the entitlement certificates for all pools using any of the the specified product(s), effective for the given owners.
 * @param owners A collection of owners for which the certificates should be generated. Pools using the given products but not owned by an owner within this collection will not have their certificates regenerated.
 * @param products A collection of products for which to regenerate affected certificates
 * @param lazy Whether or not to generate the certificate immediately, or mark it dirty and allow it to be regenerated on-demand
 */
@Transactional public void regenerateCertificatesOf(Collection<Owner> owners,Collection<Product> products,boolean lazy){
  List<Pool> pools=new LinkedList<Pool>();
  Set<String> productIds=new HashSet<String>();
  Date now=new Date();
  for (  Product product : products) {
    productIds.add(product.getId());
  }
  for (  Owner owner : owners) {
    pools.addAll(this.poolCurator.listAvailableEntitlementPools(null,owner,productIds,now,false));
  }
  for (  Pool pool : pools) {
    this.regenerateCertificatesOf(pool.getEntitlements(),lazy);
  }
}
Program: 49281
Project: 49281
Buggy source:
@Override @Transactional public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
  try {
    JobDataMap map=ctx.getMergedJobDataMap();
    String uuid=(String)map.get(JobStatus.TARGET_ID);
    Date onDate=(Date)map.get("String_Node_Str");
    Boolean calculateComplianceUntill=(Boolean)map.get("String_Node_Str");
    Boolean forceUpdate=(Boolean)map.get("String_Node_Str");
    Boolean update=(Boolean)map.get("String_Node_Str");
    Consumer consumer=consumerCurator.verifyAndLookupConsumer(uuid);
    consumerCurator.lockAndLoad(consumer);
    complianceRules.getStatus(consumer,onDate,calculateComplianceUntill,update);
    if (forceUpdate) {
      consumerCurator.update(consumer);
    }
    ctx.setResult("String_Node_Str" + consumer.getUuid());
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    ctx.setResult(e.getMessage());
    throw new JobExecutionException(e.getMessage(),e,false);
  }
}

Fixed version (ground truth):
@Override @Transactional public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
  JobDataMap map=ctx.getMergedJobDataMap();
  String uuid=(String)map.get(JobStatus.TARGET_ID);
  Date onDate=(Date)map.get("String_Node_Str");
  Boolean calculateComplianceUntill=(Boolean)map.get("String_Node_Str");
  Boolean forceUpdate=(Boolean)map.get("String_Node_Str");
  Boolean update=(Boolean)map.get("String_Node_Str");
  try {
    Consumer consumer=consumerCurator.lockAndLoadByUuid(uuid);
    if (consumer == null) {
      String message="String_Node_Str";
      log.info(message,uuid);
      ctx.setResult(String.format(message,uuid));
      return;
    }
    complianceRules.getStatus(consumer,onDate,calculateComplianceUntill,update);
    if (forceUpdate) {
      consumerCurator.update(consumer);
    }
    ctx.setResult(String.format("String_Node_Str",consumer.getUuid()));
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    ctx.setResult(e.getMessage());
    throw new JobExecutionException(e.getMessage(),e,false);
  }
}
Program: 49282
Project: 49282
Buggy source:
@Test @SuppressWarnings("String_Node_Str") public void normalCreate(){
  Consumer consumer=new Consumer("String_Node_Str","String_Node_Str",owner,ct);
  consumerCurator.create(consumer);
  List<Product> results=entityManager().createQuery("String_Node_Str").getResultList();
  assertEquals(1,results.size());
}

Fixed version (ground truth):
@Test public void normalCreate(){
  Consumer consumer=new Consumer("String_Node_Str","String_Node_Str",owner,ct);
  consumerCurator.create(consumer);
  List<Consumer> results=entityManager().createQuery("String_Node_Str",Consumer.class).getResultList();
  assertEquals(1,results.size());
}
Program: 49283
Project: 49283
Buggy source:
@Test public void scheduleSimpleStatusCheck() throws JobExecutionException {
  JobDetail detail=job.scheduleStatusCheck(consumer,new Date(),true,false);
  assertNotNull(detail);
  when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
  when(curator.verifyAndLookupConsumer(consumerUuid)).thenReturn(consumer);
  job.execute(ctx);
  verify(curator).lockAndLoad(eq(consumer));
  verify(rules).getStatus(eq(consumer),any(Date.class),eq(true),eq(false));
}

Fixed version (ground truth):
@Test public void scheduleSimpleStatusCheck() throws JobExecutionException {
  JobDetail detail=job.scheduleStatusCheck(consumer,new Date(),true,false);
  assertNotNull(detail);
  when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
  when(curator.lockAndLoadByUuid(consumerUuid)).thenReturn(consumer);
  job.execute(ctx);
  verify(curator).lockAndLoadByUuid(eq(consumerUuid));
  verify(rules).getStatus(eq(consumer),any(Date.class),eq(true),eq(false));
}
Program: 49284
Project: 49284
Buggy source:
@Test(expected=JobExecutionException.class) public void exceptionOnSchedule() throws JobExecutionException {
  JobDetail detail=job.scheduleWithForceUpdate(consumer);
  assertNotNull(detail);
  when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
  when(curator.verifyAndLookupConsumer(consumerUuid)).thenReturn(consumer);
  when(rules.getStatus(eq(consumer),any(Date.class),eq(false),eq(false))).thenThrow(new RuleExecutionException("String_Node_Str"));
  job.execute(ctx);
}

Fixed version (ground truth):
@Test(expected=JobExecutionException.class) public void exceptionOnSchedule() throws JobExecutionException {
  JobDetail detail=job.scheduleWithForceUpdate(consumer);
  assertNotNull(detail);
  when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
  when(curator.lockAndLoadByUuid(consumerUuid)).thenReturn(consumer);
  when(rules.getStatus(eq(consumer),any(Date.class),eq(false),eq(false))).thenThrow(new RuleExecutionException("String_Node_Str"));
  job.execute(ctx);
}
Program: 49285
Project: 49285
Buggy source:
@Test public void scheduleWithForceUpdateCheck() throws JobExecutionException {
  JobDetail detail=job.scheduleWithForceUpdate(consumer);
  assertNotNull(detail);
  when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
  when(curator.verifyAndLookupConsumer(consumerUuid)).thenReturn(consumer);
  job.execute(ctx);
  verify(curator).lockAndLoad(eq(consumer));
  verify(rules).getStatus(eq(consumer),any(Date.class),eq(false),eq(false));
  verify(curator).update(consumer);
}

Fixed version (ground truth):
@Test public void scheduleWithForceUpdateCheck() throws JobExecutionException {
  JobDetail detail=job.scheduleWithForceUpdate(consumer);
  assertNotNull(detail);
  when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
  when(curator.lockAndLoadByUuid(consumerUuid)).thenReturn(consumer);
  job.execute(ctx);
  verify(curator).lockAndLoadByUuid(eq(consumerUuid));
  verify(rules).getStatus(eq(consumer),any(Date.class),eq(false),eq(false));
  verify(curator).update(consumer);
}
Program: 49286
Project: 49286
Buggy source:
@Override public List<Pool> createPools(List<Pool> pools){
  if (pools != null && !pools.isEmpty()) {
    poolCurator.saveOrUpdateAll(pools);
    for (    Pool pool : pools) {
      log.debug("String_Node_Str",pool);
      if (pool != null) {
        sink.emitPoolCreated(pool);
      }
    }
  }
  return pools;
}

Fixed version (ground truth):
@Override public List<Pool> createPools(List<Pool> pools){
  if (pools != null && !pools.isEmpty()) {
    poolCurator.saveOrUpdateAll(pools,false);
    for (    Pool pool : pools) {
      log.debug("String_Node_Str",pool);
      if (pool != null) {
        sink.emitPoolCreated(pool);
      }
    }
  }
  return pools;
}
Program: 49288
Project: 49288
Buggy source:
/** 
 * Request an entitlement by product for a host system in a host-guest relationship.  Allows getBestPoolsForHost to choose products to bind.
 * @param guest consumer requesting to have host entitled
 * @param host host consumer to entitle
 * @param entitleDate specific date to entitle by.
 * @return Entitlement
 * @throws EntitlementRefusedException if entitlement is refused
 */
@Override @Transactional public List<Entitlement> entitleByProductsForHost(Consumer guest,Consumer host,Date entitleDate,Collection<String> possiblePools) throws EntitlementRefusedException {
  List<Entitlement> entitlements=new LinkedList<Entitlement>();
  if (!host.getOwner().equals(guest.getOwner())) {
    log.debug("String_Node_Str",host.getUuid(),guest.getUuid());
    return entitlements;
  }
  Owner owner=host.getOwner();
  if (entitleDate == null) {
    entitleDate=new Date();
  }
  List<PoolQuantity> bestPools=getBestPoolsForHost(guest,host,entitleDate,owner,null,possiblePools);
  if (bestPools == null) {
    log.info("String_Node_Str",host.getUuid());
    return null;
  }
  return entitleByPools(guest,convertToMap(bestPools));
}

Fixed version (ground truth):
/** 
 * Request an entitlement by product for a host system in a host-guest relationship.  Allows getBestPoolsForHost to choose products to bind.
 * @param guest consumer requesting to have host entitled
 * @param host host consumer to entitle
 * @param entitleDate specific date to entitle by.
 * @return Entitlement
 * @throws EntitlementRefusedException if entitlement is refused
 */
@Override @Transactional public List<Entitlement> entitleByProductsForHost(Consumer guest,Consumer host,Date entitleDate,Collection<String> possiblePools) throws EntitlementRefusedException {
  List<Entitlement> entitlements=new LinkedList<Entitlement>();
  if (!host.getOwner().equals(guest.getOwner())) {
    log.debug("String_Node_Str",host.getUuid(),guest.getUuid());
    return entitlements;
  }
  Owner owner=host.getOwner();
  if (entitleDate == null) {
    entitleDate=new Date();
  }
  List<PoolQuantity> bestPools=getBestPoolsForHost(guest,host,entitleDate,owner,null,possiblePools);
  if (bestPools == null) {
    log.info("String_Node_Str",host.getUuid());
    return null;
  }
  return entitleByPools(host,convertToMap(bestPools));
}
Program: 49289
Project: 49289
Buggy source:
@Override public void handleEntitlementPersist(Map<String,Entitlement> entitlements){
  List<Entitlement> entitlementsList=new ArrayList<Entitlement>(entitlements.values());
  entitlementCurator.mergeAll(entitlementsList);
}

Fixed version (ground truth):
@Override public void handleEntitlementPersist(Map<String,Entitlement> entitlements){
  List<Entitlement> entitlementsList=new ArrayList<Entitlement>(entitlements.values());
  entitlementCurator.mergeAll(entitlementsList,false);
}
Program: 49290
Project: 49290
Buggy source:
public Collection<E> mergeAll(Collection<E> entries){
  if (entries != null && !entries.isEmpty()) {
    try {
      Session session=currentSession();
      int i=0;
      Iterator<E> iter=entries.iterator();
      while (iter.hasNext()) {
        session.merge(iter.next());
        if (i % batchSize == 0) {
          session.flush();
          session.clear();
        }
        i++;
      }
      session.flush();
      session.clear();
    }
 catch (    OptimisticLockException e) {
      throw new ConcurrentModificationException(getConcurrentModificationMessage(),e);
    }
  }
  return entries;
}

Fixed version (ground truth):
public Collection<E> mergeAll(Collection<E> entries,boolean flush){
  if (entries != null && !entries.isEmpty()) {
    try {
      Session session=currentSession();
      int i=0;
      Iterator<E> iter=entries.iterator();
      while (iter.hasNext()) {
        session.merge(iter.next());
        if (i % batchSize == 0 && flush) {
          session.flush();
          session.clear();
        }
        i++;
      }
      if (flush) {
        session.flush();
        session.clear();
      }
    }
 catch (    OptimisticLockException e) {
      throw new ConcurrentModificationException(getConcurrentModificationMessage(),e);
    }
  }
  return entries;
}
Program: 49291
Project: 49291
Buggy source:
public final void flush(){
  try {
    getEntityManager().flush();
  }
 catch (  OptimisticLockException e) {
    throw new ConcurrentModificationException(getConcurrentModificationMessage(),e);
  }
}

Fixed version (ground truth):
public void flush(){
  try {
    getEntityManager().flush();
  }
 catch (  OptimisticLockException e) {
    throw new ConcurrentModificationException(getConcurrentModificationMessage(),e);
  }
}
Program: 49292
Project: 49292
Buggy source:
public Collection<E> saveOrUpdateAll(Collection<E> entries){
  if (entries != null && !entries.isEmpty()) {
    try {
      Session session=currentSession();
      int i=0;
      Iterator<E> iter=entries.iterator();
      while (iter.hasNext()) {
        session.saveOrUpdate(iter.next());
        if (i % batchSize == 0) {
          session.flush();
          session.clear();
        }
        i++;
      }
      session.flush();
      session.clear();
    }
 catch (    OptimisticLockException e) {
      throw new ConcurrentModificationException(getConcurrentModificationMessage(),e);
    }
  }
  return entries;
}

Fixed version (ground truth):
public Collection<E> saveOrUpdateAll(Collection<E> entries,boolean flush){
  if (entries != null && !entries.isEmpty()) {
    try {
      Session session=currentSession();
      int i=0;
      Iterator<E> iter=entries.iterator();
      while (iter.hasNext()) {
        session.saveOrUpdate(iter.next());
        if (i % batchSize == 0 && flush) {
          session.flush();
          session.clear();
        }
        i++;
      }
      if (flush) {
        session.flush();
        session.clear();
      }
    }
 catch (    OptimisticLockException e) {
      throw new ConcurrentModificationException(getConcurrentModificationMessage(),e);
    }
  }
  return entries;
}
Program: 49293
Project: 49293
Buggy source:
public Collection<CertificateSerial> saveOrUpdateAll(Map<String,CertificateSerial> serialMap){
  return this.saveOrUpdateAll(serialMap.values());
}

Fixed version (ground truth):
public Collection<CertificateSerial> saveOrUpdateAll(Map<String,CertificateSerial> serialMap){
  return this.saveOrUpdateAll(serialMap.values(),false);
}
Program: 49295
Project: 49295
Buggy source:
/** 
 * Updates the pool based on the entitlements in the specified stack.
 * @param pools
 * @param consumer
 */
public void updatePoolsFromStack(Consumer consumer,List<Pool> pools){
  Map<String,List<Entitlement>> entitlementMap=new HashMap<String,List<Entitlement>>();
  Map<String,Pool> poolMap=new HashMap<String,Pool>();
  Set<String> sourceStackIds=new HashSet<String>();
  for (  Pool pool : pools) {
    sourceStackIds.add(pool.getSourceStackId());
    poolMap.put(pool.getId(),pool);
  }
  List<Entitlement> stackedEnts=this.entCurator.findByStackIds(consumer,sourceStackIds);
  for (  Entitlement entitlement : stackedEnts) {
    if (!entitlementMap.containsKey(entitlement.getPool().getId())) {
      entitlementMap.put(entitlement.getPool().getId(),new ArrayList<Entitlement>());
    }
    entitlementMap.get(entitlement.getPool().getId()).add(entitlement);
  }
  for (  Entry<String,Pool> entry : poolMap.entrySet()) {
    this.updatePoolFromStackedEntitlements(entry.getValue(),entitlementMap.get(entry.getKey()),new HashSet<Product>());
  }
}

Fixed version (ground truth):
/** 
 * Updates the pool based on the entitlements in the specified stack.
 * @param pools
 * @param consumer
 */
public void updatePoolsFromStack(Consumer consumer,List<Pool> pools){
  Map<String,List<Entitlement>> entitlementMap=new HashMap<String,List<Entitlement>>();
  Map<String,Pool> poolMap=new HashMap<String,Pool>();
  Set<String> sourceStackIds=new HashSet<String>();
  for (  Pool pool : pools) {
    sourceStackIds.add(pool.getSourceStackId());
    poolMap.put(pool.getId(),pool);
  }
  List<Entitlement> stackedEnts=this.entCurator.findByStackIds(consumer,sourceStackIds);
  for (  Entitlement entitlement : stackedEnts) {
    if (!entitlementMap.containsKey(entitlement.getPool().getStackId())) {
      entitlementMap.put(entitlement.getPool().getStackId(),new ArrayList<Entitlement>());
    }
    entitlementMap.get(entitlement.getPool().getStackId()).add(entitlement);
  }
  for (  Pool pool : poolMap.values()) {
    List<Entitlement> entitlements=entitlementMap.get(pool.getSourceStackId());
    if (entitlements != null && !entitlements.isEmpty()) {
      this.updatePoolFromStackedEntitlements(pool,entitlements,new HashSet<Product>());
    }
  }
}
Program: 49298
Project: 49298
Buggy source:
public boolean syncCRLWithDB(File file) throws IOException {
  List<BigInteger> revoke=new LinkedList<BigInteger>();
  List<CertificateSerial> serials=this.certificateSerialCurator.retrieveTobeCollectedSerials();
  for (  CertificateSerial serial : serials) {
    revoke.add(serial.getSerial());
    serial.setCollected(true);
  }
  List<BigInteger> unrevoke=new LinkedList<BigInteger>();
  for (  CertificateSerial serial : this.certificateSerialCurator.getExpiredSerials()) {
    unrevoke.add(serial.getSerial());
  }
  if (revoke.size() > 0 || unrevoke.size() > 0) {
    this.updateCRLFile(file,revoke,unrevoke);
    this.certificateSerialCurator.saveOrUpdateAll(serials);
  }
  return true;
}

Fixed version (ground truth):
public boolean syncCRLWithDB(File file) throws IOException {
  List<BigInteger> revoke=new LinkedList<BigInteger>();
  List<CertificateSerial> serials=this.certificateSerialCurator.retrieveTobeCollectedSerials();
  for (  CertificateSerial serial : serials) {
    revoke.add(serial.getSerial());
    serial.setCollected(true);
  }
  List<BigInteger> unrevoke=new LinkedList<BigInteger>();
  for (  CertificateSerial serial : this.certificateSerialCurator.getExpiredSerials()) {
    unrevoke.add(serial.getSerial());
  }
  if (revoke.size() > 0 || unrevoke.size() > 0) {
    this.updateCRLFile(file,revoke,unrevoke);
    this.certificateSerialCurator.saveOrUpdateAll(serials,true);
  }
  return true;
}
Program: 49299
Project: 49299
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void testEntitleWithADate() throws Exception {
  Product product=TestUtil.createProduct(o);
  List<Pool> pools=Util.newList();
  Pool pool1=TestUtil.createPool(product);
  pools.add(pool1);
  Pool pool2=TestUtil.createPool(product);
  pools.add(pool2);
  Date now=new Date();
  ValidationResult result=mock(ValidationResult.class);
  Page page=mock(Page.class);
  when(page.getPageData()).thenReturn(pools);
  when(mockPoolCurator.listAvailableEntitlementPools(any(Consumer.class),any(Owner.class),any(String.class),any(String.class),eq(now),anyBoolean(),any(PoolFilterBuilder.class),any(PageRequest.class),anyBoolean())).thenReturn(page);
  when(mockPoolCurator.lockAndLoad(any(List.class))).thenReturn(Arrays.asList(pool1));
  when(enforcerMock.preEntitlement(any(Consumer.class),any(Pool.class),anyInt(),any(CallerType.class))).thenReturn(result);
  when(result.isSuccessful()).thenReturn(true);
  List<PoolQuantity> bestPools=new ArrayList<PoolQuantity>();
  bestPools.add(new PoolQuantity(pool1,1));
  when(autobindRules.selectBestPools(any(Consumer.class),any(String[].class),any(List.class),any(ComplianceStatus.class),any(String.class),any(Set.class),eq(false))).thenReturn(bestPools);
  AutobindData data=AutobindData.create(TestUtil.createConsumer(o)).forProducts(new String[]{product.getUuid()}).on(now);
  List<Entitlement> e=manager.entitleByProducts(data);
  assertNotNull(e);
  assertEquals(e.size(),1);
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void testEntitleWithADate() throws Exception {
  Product product=TestUtil.createProduct(o);
  List<Pool> pools=Util.newList();
  Pool pool1=TestUtil.createPool(product);
  pools.add(pool1);
  Pool pool2=TestUtil.createPool(product);
  pools.add(pool2);
  Date now=new Date();
  ValidationResult result=mock(ValidationResult.class);
  Page page=mock(Page.class);
  when(page.getPageData()).thenReturn(pools);
  when(mockPoolCurator.listAvailableEntitlementPools(any(Consumer.class),any(Owner.class),any(String.class),any(String.class),eq(now),anyBoolean(),any(PoolFilterBuilder.class),any(PageRequest.class),anyBoolean())).thenReturn(page);
  when(mockPoolCurator.lockAndLoad(any(List.class))).thenReturn(Arrays.asList(pool1));
  when(enforcerMock.preEntitlement(any(Consumer.class),any(Pool.class),anyInt(),any(CallerType.class))).thenReturn(result);
  when(result.isSuccessful()).thenReturn(true);
  List<PoolQuantity> bestPools=new ArrayList<PoolQuantity>();
  bestPools.add(new PoolQuantity(pool1,1));
  when(autobindRules.selectBestPools(any(Consumer.class),any(String[].class),any(List.class),any(ComplianceStatus.class),any(String.class),any(Set.class),eq(false))).thenReturn(bestPools);
  AutobindData data=AutobindData.create(TestUtil.createConsumer(o)).forProducts(new String[]{product.getUuid()}).on(now);
  doNothing().when(mockPoolCurator).flush();
  doNothing().when(mockPoolCurator).clear();
  List<Entitlement> e=manager.entitleByProducts(data);
  assertNotNull(e);
  assertEquals(e.size(),1);
}
Program: 49301
Project: 49301
Buggy source:
private Set<String> processPoolUpdates(Map<String,EventBuilder> poolEvents,List<PoolUpdate> updatedPools){
  Set<String> entitlementsToRegen=Util.newSet();
  for (  PoolUpdate updatedPool : updatedPools) {
    Pool existingPool=updatedPool.getPool();
    log.info("String_Node_Str",updatedPool.toString());
    if (existingPool.isMarkedForDelete()) {
      log.warn("String_Node_Str",existingPool.getId());
      deletePool(existingPool);
      continue;
    }
    this.poolCurator.merge(existingPool);
    this.poolCurator.flush();
    if (updatedPool.getQuantityChanged()) {
      this.deleteExcessEntitlements(existingPool);
    }
    if (updatedPool.getDatesChanged() || updatedPool.getProductsChanged() || updatedPool.getBrandingChanged()) {
      List<String> entitlements=poolCurator.retrieveFreeEntitlementIdsOfPool(existingPool,true);
      entitlementsToRegen.addAll(entitlements);
    }
    Event event=poolEvents.get(existingPool.getId()).setNewEntity(existingPool).buildEvent();
    sink.queueEvent(event);
  }
  return entitlementsToRegen;
}

Fixed version (ground truth):
private Set<String> processPoolUpdates(Map<String,EventBuilder> poolEvents,List<PoolUpdate> updatedPools){
  Set<String> entitlementsToRegen=Util.newSet();
  for (  PoolUpdate updatedPool : updatedPools) {
    Pool existingPool=updatedPool.getPool();
    log.info("String_Node_Str",updatedPool.toString());
    if (existingPool.isMarkedForDelete()) {
      log.warn("String_Node_Str",existingPool.getId());
      deletePool(existingPool);
      continue;
    }
    this.poolCurator.merge(existingPool);
    this.poolCurator.flush();
    if (updatedPool.getQuantityChanged()) {
      this.deleteExcessEntitlements(existingPool);
    }
    if (updatedPool.getDatesChanged() || updatedPool.getProductsChanged() || updatedPool.getBrandingChanged()) {
      List<String> entitlements=poolCurator.retrieveFreeEntitlementIdsOfPool(existingPool,true);
      entitlementsToRegen.addAll(entitlements);
    }
    EventBuilder builder=poolEvents.get(existingPool.getId());
    if (builder != null) {
      Event event=builder.setNewEntity(existingPool).buildEvent();
      sink.queueEvent(event);
    }
 else {
      log.warn("String_Node_Str",existingPool);
    }
  }
  return entitlementsToRegen;
}
Program: 49302
Project: 49302
Buggy source:
public Pool findDevPool(Consumer consumer){
  PoolFilterBuilder filters=new PoolFilterBuilder();
  filters.addAttributeFilter(Pool.DEVELOPMENT_POOL_ATTRIBUTE,"String_Node_Str");
  filters.addAttributeFilter(Pool.REQUIRES_CONSUMER_ATTRIBUTE,consumer.getUuid());
  Criteria criteria=currentSession().createCriteria(Pool.class);
  filters.applyTo(criteria);
  criteria.setMaxResults(1).uniqueResult();
  return (Pool)criteria.uniqueResult();
}

Fixed version (ground truth):
public Pool findDevPool(Consumer consumer){
  PoolFilterBuilder filters=new PoolFilterBuilder();
  filters.addAttributeFilter(Pool.DEVELOPMENT_POOL_ATTRIBUTE,"String_Node_Str");
  filters.addAttributeFilter(Pool.REQUIRES_CONSUMER_ATTRIBUTE,consumer.getUuid());
  Criteria criteria=currentSession().createCriteria(Pool.class);
  criteria.add(Restrictions.eq("String_Node_Str",consumer.getOwner()));
  filters.applyTo(criteria);
  criteria.setMaxResults(1).uniqueResult();
  return (Pool)criteria.uniqueResult();
}
Program: 49303
Project: 49303
Buggy source:
@Test public void testDevPoolForConsumerNotFoundReturnsNullWhenNoMatchOnConsumer() throws Exception {
  Pool pool=createPool(owner,product,-1L,TestUtil.createDate(2010,3,2),TestUtil.createDate(Calendar.getInstance().get(Calendar.YEAR) + 1,3,2));
  pool.setAttribute("String_Node_Str","String_Node_Str");
  pool.setAttribute("String_Node_Str","String_Node_Str");
  poolCurator.create(pool);
  Pool found=poolCurator.findDevPool(consumer);
  assertNull(found);
}

Fixed version (ground truth):
@Test public void testDevPoolForConsumerNotFoundReturnsNullWhenNoMatchOnConsumer() throws Exception {
  createPool(owner,product,-1L,TestUtil.createDate(2010,3,2),TestUtil.createDate(Calendar.getInstance().get(Calendar.YEAR) + 1,3,2));
  Pool pool=createPool(owner,product,-1L,TestUtil.createDate(2010,3,2),TestUtil.createDate(Calendar.getInstance().get(Calendar.YEAR) + 1,3,2));
  pool.setAttribute("String_Node_Str","String_Node_Str");
  pool.setAttribute("String_Node_Str","String_Node_Str");
  poolCurator.create(pool);
  Pool found=poolCurator.findDevPool(consumer);
  assertNull(found);
}
Program: 49304
Project: 49304
Buggy source:
@Test public void testLookupDevPoolForConsumer() throws Exception {
  Pool pool=createPool(owner,product,-1L,TestUtil.createDate(2010,3,2),TestUtil.createDate(Calendar.getInstance().get(Calendar.YEAR) + 1,3,2));
  pool.setAttribute("String_Node_Str",consumer.getUuid());
  pool.setAttribute("String_Node_Str","String_Node_Str");
  poolCurator.create(pool);
  Pool found=poolCurator.findDevPool(consumer);
  assertNotNull(found);
  assertEquals(pool.getId(),found.getId());
}

Fixed version (ground truth):
@Test public void testLookupDevPoolForConsumer() throws Exception {
  createPool(owner,product,-1L,TestUtil.createDate(2010,3,2),TestUtil.createDate(Calendar.getInstance().get(Calendar.YEAR) + 1,3,2));
  Pool pool=createPool(owner,product,-1L,TestUtil.createDate(2010,3,2),TestUtil.createDate(Calendar.getInstance().get(Calendar.YEAR) + 1,3,2));
  pool.setAttribute("String_Node_Str",consumer.getUuid());
  pool.setAttribute("String_Node_Str","String_Node_Str");
  pool.setAttribute("String_Node_Str","String_Node_Str");
  poolCurator.create(pool);
  Pool found=poolCurator.findDevPool(consumer);
  assertNotNull(found);
  assertEquals(pool.getId(),found.getId());
}
Program: 49305
Project: 49305
Buggy source:
/** 
 * Update pool for master pool.
 * @param existingPools the existing pools
 * @param pool the master pool
 * @param updateStackDerived whether or not to attempt to update stackderived pools
 */
Set<String> updatePoolsForMasterPool(List<Pool> existingPools,Pool pool,boolean updateStackDerived,Set<Product> changedProducts){
  if (existingPools == null || existingPools.isEmpty()) {
    return new HashSet<String>(0);
  }
  log.debug("String_Node_Str",existingPools.size(),pool);
  Map<String,EventBuilder> poolEvents=new HashMap<String,EventBuilder>();
  for (  Pool existing : existingPools) {
    EventBuilder eventBuilder=eventFactory.getEventBuilder(Target.POOL,Type.MODIFIED).setOldEntity(existing);
    poolEvents.put(existing.getId(),eventBuilder);
  }
  List<PoolUpdate> updatedPools=poolRules.updatePools(pool,existingPools,changedProducts);
  String virtLimit=pool.getProduct().getAttributeValue("String_Node_Str");
  boolean createsSubPools=!StringUtils.isBlank(virtLimit) && !"String_Node_Str".equals(virtLimit);
  if (updateStackDerived && !updatedPools.isEmpty() && createsSubPools&& pool.isStacked()) {
    List<Pool> subPools=getOwnerSubPoolsForStackId(pool.getOwner(),pool.getStackId());
    for (    Pool subPool : subPools) {
      PoolUpdate update=updatePoolFromStack(subPool,changedProducts);
      if (update.changed()) {
        updatedPools.add(update);
      }
    }
  }
  Set<String> entsToRegen=processPoolUpdates(poolEvents,updatedPools);
  return entsToRegen;
}

Fixed version (ground truth):
/** 
 * Update pool for master pool.
 * @param existingPools the existing pools
 * @param pool the master pool
 * @param originalQuantity the pool's original quantity before multiplier was applied
 * @param updateStackDerived whether or not to attempt to update stackderived pools
 */
Set<String> updatePoolsForMasterPool(List<Pool> existingPools,Pool pool,Long originalQuantity,boolean updateStackDerived,Set<Product> changedProducts){
  if (existingPools == null || existingPools.isEmpty()) {
    return new HashSet<String>(0);
  }
  log.debug("String_Node_Str",existingPools.size(),pool);
  Map<String,EventBuilder> poolEvents=new HashMap<String,EventBuilder>();
  for (  Pool existing : existingPools) {
    EventBuilder eventBuilder=eventFactory.getEventBuilder(Target.POOL,Type.MODIFIED).setOldEntity(existing);
    poolEvents.put(existing.getId(),eventBuilder);
  }
  List<PoolUpdate> updatedPools=poolRules.updatePools(pool,existingPools,originalQuantity,changedProducts);
  String virtLimit=pool.getProduct().getAttributeValue("String_Node_Str");
  boolean createsSubPools=!StringUtils.isBlank(virtLimit) && !"String_Node_Str".equals(virtLimit);
  if (updateStackDerived && !updatedPools.isEmpty() && createsSubPools&& pool.isStacked()) {
    List<Pool> subPools=getOwnerSubPoolsForStackId(pool.getOwner(),pool.getStackId());
    for (    Pool subPool : subPools) {
      PoolUpdate update=updatePoolFromStack(subPool,changedProducts);
      if (update.changed()) {
        updatedPools.add(update);
      }
    }
  }
  Set<String> entsToRegen=processPoolUpdates(poolEvents,updatedPools);
  return entsToRegen;
}
Program: 49306
Project: 49306
Buggy source:
@Transactional void refreshPoolsForMasterPool(Pool pool,boolean updateStackDerived,boolean lazy,Set<Product> changedProducts){
  List<Pool> subscriptionPools=poolCurator.getPoolsBySubscriptionId(pool.getSubscriptionId());
  log.debug("String_Node_Str",subscriptionPools.size(),pool.getSubscriptionId());
  if (log.isDebugEnabled()) {
    for (    Pool p : subscriptionPools) {
      log.debug("String_Node_Str",p.getOwner().getKey(),p);
    }
  }
  removeAndDeletePoolsOnOtherOwners(subscriptionPools,pool);
  createAndEnrichPools(pool,subscriptionPools);
  regenerateCertificatesByEntIds(updatePoolsForMasterPool(subscriptionPools,pool,updateStackDerived,changedProducts),lazy);
}

Fixed version (ground truth):
@Transactional void refreshPoolsForMasterPool(Pool pool,boolean updateStackDerived,boolean lazy,Set<Product> changedProducts){
  List<Pool> subscriptionPools=poolCurator.getPoolsBySubscriptionId(pool.getSubscriptionId());
  log.debug("String_Node_Str",subscriptionPools.size(),pool.getSubscriptionId());
  if (log.isDebugEnabled()) {
    for (    Pool p : subscriptionPools) {
      log.debug("String_Node_Str",p.getOwner().getKey(),p);
    }
  }
  removeAndDeletePoolsOnOtherOwners(subscriptionPools,pool);
  Long originalQuantity=pool.getQuantity();
  createAndEnrichPools(pool,subscriptionPools);
  regenerateCertificatesByEntIds(updatePoolsForMasterPool(subscriptionPools,pool,originalQuantity,updateStackDerived,changedProducts),lazy);
}
Program: 49308
Project: 49308
Buggy source:
private boolean checkForQuantityChange(Pool pool,Pool existingPool,List<Pool> existingPools,Map<String,String> attributes){
  long expectedQuantity=calculateQuantity(pool.getQuantity(),pool.getProduct(),pool.getUpstreamPoolId());
  expectedQuantity=processVirtLimitPools(existingPools,attributes,existingPool,expectedQuantity);
  boolean quantityChanged=!(expectedQuantity == existingPool.getQuantity());
  if (quantityChanged) {
    existingPool.setQuantity(expectedQuantity);
  }
  return quantityChanged;
}

Fixed version (ground truth):
private boolean checkForQuantityChange(Pool pool,Pool existingPool,Long originalQuantity,List<Pool> existingPools,Map<String,String> attributes){
  long expectedQuantity=calculateQuantity(originalQuantity,pool.getProduct(),pool.getUpstreamPoolId());
  expectedQuantity=processVirtLimitPools(existingPools,attributes,existingPool,expectedQuantity);
  boolean quantityChanged=!(expectedQuantity == existingPool.getQuantity());
  if (quantityChanged) {
    existingPool.setQuantity(expectedQuantity);
  }
  return quantityChanged;
}
Program: 49309
Project: 49309
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void refreshPoolsCleanupPoolThatLostVirtLimit(){
  List<Subscription> subscriptions=Util.newList();
  List<Pool> pools=Util.newList();
  Subscription s=TestUtil.createSubscription(getOwner(),TestUtil.createProduct(o));
  s.setId("String_Node_Str");
  subscriptions.add(s);
  Pool p=TestUtil.createPool(s.getProduct());
  p.setSourceSubscription(new SourceSubscription(s.getId(),"String_Node_Str"));
  p.setMarkedForDelete(true);
  p.setOwner(s.getOwner());
  pools.add(p);
  mockSubsList(subscriptions);
  mockPoolsList(pools);
  List<PoolUpdate> updates=new LinkedList();
  PoolUpdate u=new PoolUpdate(p);
  u.setQuantityChanged(true);
  u.setOrderChanged(true);
  updates.add(u);
  ArgumentCaptor<Pool> argPool=ArgumentCaptor.forClass(Pool.class);
  when(poolRulesMock.updatePools(argPool.capture(),eq(pools),any(Set.class))).thenReturn(updates);
  when(ownerCuratorMock.lookupByKey(s.getOwner().getKey())).thenReturn(s.getOwner());
  this.manager.getRefresher(mockSubAdapter).add(getOwner()).run();
  verify(poolRulesMock).createAndEnrichPools(argPool.capture(),any(List.class));
  TestUtil.assertPoolsAreEqual(TestUtil.copyFromSub(s),argPool.getValue());
  verify(this.mockPoolCurator,times(1)).delete(any(Pool.class));
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void refreshPoolsCleanupPoolThatLostVirtLimit(){
  List<Subscription> subscriptions=Util.newList();
  List<Pool> pools=Util.newList();
  Subscription s=TestUtil.createSubscription(getOwner(),TestUtil.createProduct(o));
  s.setId("String_Node_Str");
  subscriptions.add(s);
  Pool p=TestUtil.createPool(s.getProduct());
  p.setSourceSubscription(new SourceSubscription(s.getId(),"String_Node_Str"));
  p.setMarkedForDelete(true);
  p.setOwner(s.getOwner());
  pools.add(p);
  mockSubsList(subscriptions);
  mockPoolsList(pools);
  List<PoolUpdate> updates=new LinkedList();
  PoolUpdate u=new PoolUpdate(p);
  u.setQuantityChanged(true);
  u.setOrderChanged(true);
  updates.add(u);
  ArgumentCaptor<Pool> argPool=ArgumentCaptor.forClass(Pool.class);
  when(poolRulesMock.updatePools(argPool.capture(),eq(pools),eq(s.getQuantity()),any(Set.class))).thenReturn(updates);
  when(ownerCuratorMock.lookupByKey(s.getOwner().getKey())).thenReturn(s.getOwner());
  this.manager.getRefresher(mockSubAdapter).add(getOwner()).run();
  verify(poolRulesMock).createAndEnrichPools(argPool.capture(),any(List.class));
  TestUtil.assertPoolsAreEqual(TestUtil.copyFromSub(s),argPool.getValue());
  verify(this.mockPoolCurator,times(1)).delete(any(Pool.class));
}
Program: 49310
Project: 49310
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void testRefreshPoolsOnlyRegeneratesWhenNecessary(){
  List<Subscription> subscriptions=Util.newList();
  Product product=TestUtil.createProduct(o);
  Subscription sub=TestUtil.createSubscription(getOwner(),product);
  sub.setId("String_Node_Str");
  subscriptions.add(sub);
  List<Pool> pools=Util.newList();
  Pool p=TestUtil.createPool(product);
  p.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
  p.setOwner(sub.getOwner());
  pools.add(p);
  mockSubsList(subscriptions);
  mockPoolsList(pools);
  when(ownerCuratorMock.lookupByKey(sub.getOwner().getKey())).thenReturn(sub.getOwner());
  this.manager.getRefresher(mockSubAdapter).add(getOwner()).run();
  List<Pool> expectedModified=new LinkedList();
  expectedModified.add(p);
  verify(this.manager).updateFloatingPools(eq(new LinkedList()),eq(true),any(Set.class));
  ArgumentCaptor<Pool> argPool=ArgumentCaptor.forClass(Pool.class);
  verify(this.manager).updatePoolsForMasterPool(eq(expectedModified),argPool.capture(),eq(false),any(Set.class));
  TestUtil.assertPoolsAreEqual(TestUtil.copyFromSub(sub),argPool.getValue());
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Test public void testRefreshPoolsOnlyRegeneratesWhenNecessary(){
  List<Subscription> subscriptions=Util.newList();
  Product product=TestUtil.createProduct(o);
  Subscription sub=TestUtil.createSubscription(getOwner(),product);
  sub.setId("String_Node_Str");
  subscriptions.add(sub);
  List<Pool> pools=Util.newList();
  Pool p=TestUtil.createPool(product);
  p.setSourceSubscription(new SourceSubscription(sub.getId(),"String_Node_Str"));
  p.setOwner(sub.getOwner());
  pools.add(p);
  mockSubsList(subscriptions);
  mockPoolsList(pools);
  when(ownerCuratorMock.lookupByKey(sub.getOwner().getKey())).thenReturn(sub.getOwner());
  this.manager.getRefresher(mockSubAdapter).add(getOwner()).run();
  List<Pool> expectedModified=new LinkedList();
  expectedModified.add(p);
  verify(this.manager).updateFloatingPools(eq(new LinkedList()),eq(true),any(Set.class));
  ArgumentCaptor<Pool> argPool=ArgumentCaptor.forClass(Pool.class);
  verify(this.manager).updatePoolsForMasterPool(eq(expectedModified),argPool.capture(),eq(sub.getQuantity()),eq(false),any(Set.class));
  TestUtil.assertPoolsAreEqual(TestUtil.copyFromSub(sub),argPool.getValue());
}
Program: 49311
Project: 49311
Buggy source:
@Test public void testPoolOnlyExaminedOnceProductAndOwner(){
  Owner owner=TestUtil.createOwner();
  Product product=mock(Product.class);
  when(product.getUuid()).thenReturn("String_Node_Str");
  Pool pool=new Pool();
  pool.setSourceSubscription(new SourceSubscription("String_Node_Str","String_Node_Str"));
  pool.setOwner(owner);
  Subscription subscription=new Subscription();
  subscription.setId("String_Node_Str");
  subscription.setOwner(owner);
  List<Pool> pools=Util.newList();
  pools.add(pool);
  List<Subscription> subscriptions=Util.newList();
  subscriptions.add(subscription);
  when(subAdapter.getSubscriptions(product)).thenReturn(subscriptions);
  when(subAdapter.getSubscriptions(owner)).thenReturn(subscriptions);
  when(subAdapter.getSubscription("String_Node_Str")).thenReturn(subscription);
  when(poolManager.lookupBySubscriptionId("String_Node_Str")).thenReturn(pools);
  refresher.add(owner);
  refresher.add(product);
  refresher.run();
  verify(poolManager,times(1)).refreshPoolsWithRegeneration(eq(subAdapter),eq(owner),eq(false));
  verify(poolManager,times(0)).updatePoolsForMasterPool(any(List.class),any(Pool.class),eq(false),any(Set.class));
}

Fixed version (ground truth):
@Test public void testPoolOnlyExaminedOnceProductAndOwner(){
  Owner owner=TestUtil.createOwner();
  Product product=mock(Product.class);
  when(product.getUuid()).thenReturn("String_Node_Str");
  Pool pool=new Pool();
  pool.setSourceSubscription(new SourceSubscription("String_Node_Str","String_Node_Str"));
  pool.setOwner(owner);
  Subscription subscription=new Subscription();
  subscription.setId("String_Node_Str");
  subscription.setOwner(owner);
  List<Pool> pools=Util.newList();
  pools.add(pool);
  List<Subscription> subscriptions=Util.newList();
  subscriptions.add(subscription);
  when(subAdapter.getSubscriptions(product)).thenReturn(subscriptions);
  when(subAdapter.getSubscriptions(owner)).thenReturn(subscriptions);
  when(subAdapter.getSubscription("String_Node_Str")).thenReturn(subscription);
  when(poolManager.lookupBySubscriptionId("String_Node_Str")).thenReturn(pools);
  refresher.add(owner);
  refresher.add(product);
  refresher.run();
  verify(poolManager,times(1)).refreshPoolsWithRegeneration(eq(subAdapter),eq(owner),eq(false));
  verify(poolManager,times(0)).updatePoolsForMasterPool(any(List.class),any(Pool.class),eq(pool.getQuantity()),eq(false),any(Set.class));
}
Program: 49312
Project: 49312
Buggy source:
@Test public void hostedInstanceBasedRemoved(){
  Subscription s=createInstanceBasedSub("String_Node_Str",100,2,false);
  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);
  ProductAttribute pa=masterPool.getProduct().getAttribute("String_Node_Str");
  masterPool.getProduct().getAttributes().remove(pa);
  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(100),update.getPool().getQuantity());
  assertFalse(update.getPool().getProduct().hasAttribute("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void hostedInstanceBasedRemoved(){
  Subscription s=createInstanceBasedSub("String_Node_Str",100,2,false);
  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);
  ProductAttribute pa=masterPool.getProduct().getAttribute("String_Node_Str");
  masterPool.getProduct().getAttributes().remove(pa);
  List<Pool> existingPools=new LinkedList<Pool>();
  existingPools.add(pool);
  List<PoolUpdate> updates=poolRules.updatePools(masterPool,existingPools,s.getQuantity(),TestUtil.stubChangedProducts(masterPool.getProduct()));
  assertEquals(1,updates.size());
  PoolUpdate update=updates.get(0);
  assertTrue(update.getQuantityChanged());
  assertEquals(new Long(100),update.getPool().getQuantity());
  assertFalse(update.getPool().getProduct().hasAttribute("String_Node_Str"));
}