nus-yam/ex-repair huggingface dataset:
Program: 49516
Project: 49516
Buggy source:
/** 
 * @return a Pool
 * @httpcode 400
 * @httpcode 200
 */
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Pool addPoolToKey(@PathParam("String_Node_Str") @Verify(ActivationKey.class) String activationKeyId,@PathParam("String_Node_Str") @Verify(value=Pool.class,require=Access.READ_POOLS) String poolId,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") long quantity){
  if (quantity < 1) {
    throw new BadRequestException(i18n.tr("String_Node_Str"));
  }
  ActivationKey key=findKey(activationKeyId);
  Pool pool=findPool(poolId);
  if (pool.getAttributeValue("String_Node_Str") != null && pool.getAttributeValue("String_Node_Str").equals("String_Node_Str") || pool.getProductAttribute("String_Node_Str") != null && pool.getProductAttribute("String_Node_Str").getValue().equals("String_Node_Str")) {
    throw new BadRequestException(i18n.tr("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"));
  }
  if (quantity > 1) {
    ProductPoolAttribute ppa=pool.getProductAttribute("String_Node_Str");
    if (ppa == null || !ppa.getValue().equalsIgnoreCase("String_Node_Str")) {
      throw new BadRequestException(i18n.tr("String_Node_Str" + "String_Node_Str" + "String_Node_Str"));
    }
  }
  if ((!pool.isUnlimited()) && (quantity > pool.getQuantity())) {
    throw new BadRequestException(i18n.tr("String_Node_Str" + "String_Node_Str"));
  }
  key.addPool(pool,quantity);
  activationKeyCurator.update(key);
  return pool;
}

Fixed version (ground truth):
/** 
 * @return a Pool
 * @httpcode 400
 * @httpcode 200
 */
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Pool addPoolToKey(@PathParam("String_Node_Str") @Verify(ActivationKey.class) String activationKeyId,@PathParam("String_Node_Str") @Verify(value=Pool.class,require=Access.READ_POOLS) String poolId,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") long quantity){
  if (quantity < 1) {
    throw new BadRequestException(i18n.tr("String_Node_Str"));
  }
  ActivationKey key=findKey(activationKeyId);
  Pool pool=findPool(poolId);
  if (pool.getAttributeValue("String_Node_Str") != null && pool.getAttributeValue("String_Node_Str").equals("String_Node_Str") || pool.getProductAttribute("String_Node_Str") != null && pool.getProductAttribute("String_Node_Str").getValue().equals("String_Node_Str")) {
    throw new BadRequestException(i18n.tr("String_Node_Str" + "String_Node_Str"));
  }
  if (quantity > 1) {
    ProductPoolAttribute ppa=pool.getProductAttribute("String_Node_Str");
    if (ppa == null || !ppa.getValue().equalsIgnoreCase("String_Node_Str")) {
      throw new BadRequestException(i18n.tr("String_Node_Str" + "String_Node_Str" + "String_Node_Str"));
    }
  }
  if ((!pool.isUnlimited()) && (quantity > pool.getQuantity())) {
    throw new BadRequestException(i18n.tr("String_Node_Str" + "String_Node_Str"));
  }
  key.addPool(pool,quantity);
  activationKeyCurator.update(key);
  return pool;
}
Program: 49517
Project: 49517
Buggy source:
public void store(Owner owner,ConsumerDto consumer) throws SyncDataFormatException {
  if (consumer.getUuid() == null) {
    throw new SyncDataFormatException(i18n.tr("String_Node_Str"));
  }
  Owner alreadyUsing=curator.lookupWithUpstreamUuid(consumer.getUuid());
  if (alreadyUsing != null && alreadyUsing.getKey() != owner.getKey()) {
    throw new SyncDataFormatException(i18n.tr("String_Node_Str"));
  }
  if (owner.getUpstreamUuid() != null && !owner.getUpstreamUuid().equals(consumer.getUuid())) {
    throw new SyncDataFormatException(i18n.tr("String_Node_Str"));
  }
  owner.setUpstreamUuid(consumer.getUuid());
  curator.merge(owner);
}

Fixed version (ground truth):
public void store(Owner owner,ConsumerDto consumer) throws SyncDataFormatException {
  if (consumer.getUuid() == null) {
    throw new SyncDataFormatException(i18n.tr("String_Node_Str"));
  }
  Owner alreadyUsing=curator.lookupWithUpstreamUuid(consumer.getUuid());
  if (alreadyUsing != null && !alreadyUsing.getKey().equals(owner.getKey())) {
    log.error("String_Node_Str" + owner.getKey());
    log.error("String_Node_Str" + consumer.getUuid() + "String_Node_Str"+ alreadyUsing.getKey());
    throw new SyncDataFormatException(i18n.tr("String_Node_Str"));
  }
  if (owner.getUpstreamUuid() != null && !owner.getUpstreamUuid().equals(consumer.getUuid())) {
    throw new SyncDataFormatException(i18n.tr("String_Node_Str"));
  }
  owner.setUpstreamUuid(consumer.getUuid());
  curator.merge(owner);
}
Program: 49518
Project: 49518
Buggy source:
@Transactional public void createOrUpdate(Content c){
  Content existing=findByLabel(c.getLabel());
  if (existing == null) {
    create(c);
    return;
  }
 else {
    merge(c);
  }
}

Fixed version (ground truth):
@Transactional public void createOrUpdate(Content c){
  Content existing=find(c.getId());
  if (existing == null) {
    create(c);
    return;
  }
 else {
    merge(c);
  }
}
Program: 49519
Project: 49519
Buggy source:
@Transactional public Pool replicate(Pool pool){
  for (  ProvidedProduct pp : pool.getProvidedProducts()) {
    pp.setPool(pool);
  }
  for (  PoolAttribute pa : pool.getAttributes()) {
    pa.setPool(pool);
  }
  pool.setSourceEntitlement(null);
  this.currentSession().replicate(pool,ReplicationMode.EXCEPTION);
  return pool;
}

Fixed version (ground truth):
@Transactional public Pool replicate(Pool pool){
  for (  ProvidedProduct pp : pool.getProvidedProducts()) {
    pp.setPool(pool);
  }
  for (  PoolAttribute pa : pool.getAttributes()) {
    pa.setPool(pool);
  }
  for (  ProductPoolAttribute ppa : pool.getProductAttributes()) {
    ppa.setPool(pool);
  }
  pool.setSourceEntitlement(null);
  this.currentSession().replicate(pool,ReplicationMode.EXCEPTION);
  return pool;
}
Program: 49520
Project: 49520
Buggy source:
/** 
 * Connects to another Candlepin instance located at the given uri.
 * @param clazz the client class to create.
 * @param creds authentication credentials for the given uri.
 * @param uri the Candlepin instance to connect to
 * @return Client proxy used to interact with Candlepin via REST API.
 */
public <T>T connect(Class<T> clazz,Credentials creds,String uri){
  HttpClient httpclient=new HttpClient();
  httpclient.getState().setCredentials(AuthScope.ANY,creds);
  ClientExecutor clientExecutor=new ApacheHttpClientExecutor(httpclient);
  return ProxyFactory.create(clazz,uri,clientExecutor);
}

Fixed version (ground truth):
/** 
 * Connects to another Candlepin instance located at the given uri.
 * @param clazz the client class to create.
 * @param creds authentication credentials for the given uri.
 * @param uri the Candlepin instance to connect to
 * @return Client proxy used to interact with Candlepin via REST API.
 */
public <T>T connect(Class<T> clazz,Credentials creds,String uri){
  HttpClient httpclient=new HttpClient();
  httpclient.getParams().setAuthenticationPreemptive(true);
  httpclient.getState().setCredentials(AuthScope.ANY,creds);
  ClientExecutor clientExecutor=new ApacheHttpClientExecutor(httpclient);
  return ProxyFactory.create(clazz,uri,clientExecutor);
}
Program: 49521
Project: 49521
Buggy source:
/** 
 * Lookup consumer by its name
 * @param name consumer name to find
 * @return Consumer whose name matches the given name, null otherwise.
 */
@Transactional @EnforceAccessControl public Consumer findByName(String name){
  return (Consumer)currentSession().createCriteria(Consumer.class).add(Restrictions.eq("String_Node_Str",name)).uniqueResult();
}

Fixed version (ground truth):
/** 
 * Lookup consumer by its name
 * @param name consumer name to find
 * @return Consumer whose name matches the given name, null otherwise.
 */
@Transactional @EnforceAccessControl public Consumer findByName(Owner o,String name){
  return (Consumer)currentSession().createCriteria(Consumer.class).add(Restrictions.eq("String_Node_Str",name)).add(Restrictions.eq("String_Node_Str",o)).uniqueResult();
}
Program: 49522
Project: 49522
Buggy source:
/** 
 * @return an EntitlementCertificate
 * @httpcode 404
 * @httpcode 200
 */
@GET @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public EntitlementCertificate getUeberCertificate(@Context Principal principal,@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey){
  Owner o=findOwner(ownerKey);
  if (o == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",ownerKey));
  }
  Consumer ueberConsumer=consumerCurator.findByName(UEBER_CERT_CONSUMER);
  if (ueberConsumer == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",o.getKey()));
  }
  List<EntitlementCertificate> ueberCertificate=entitlementCertCurator.listForConsumer(ueberConsumer);
  return ueberCertificate.get(0);
}

Fixed version (ground truth):
/** 
 * @return an EntitlementCertificate
 * @httpcode 404
 * @httpcode 200
 */
@GET @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public EntitlementCertificate getUeberCertificate(@Context Principal principal,@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey){
  Owner o=findOwner(ownerKey);
  if (o == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",ownerKey));
  }
  Consumer ueberConsumer=consumerCurator.findByName(o,UEBER_CERT_CONSUMER);
  if (ueberConsumer == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",o.getKey()));
  }
  List<EntitlementCertificate> ueberCertificate=entitlementCertCurator.listForConsumer(ueberConsumer);
  return ueberCertificate.get(0);
}
Program: 49523
Project: 49523
Buggy source:
/** 
 * @return an EntitlementCertificate
 * @httpcode 400
 * @httpcode 404
 * @httpcode 200
 */
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public EntitlementCertificate createUeberCertificate(@Context Principal principal,@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey){
  Owner o=findOwner(ownerKey);
  if (o == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",ownerKey));
  }
  Consumer ueberConsumer=consumerCurator.findByName(UEBER_CERT_CONSUMER);
  if (ueberConsumer != null) {
    List<Entitlement> ueberEntitlement=entitlementCurator.listByConsumer(ueberConsumer);
    poolManager.regenerateCertificatesOf(ueberEntitlement.get(0),true);
    return entitlementCertCurator.listForConsumer(ueberConsumer).get(0);
  }
  try {
    Product ueberProduct=createUeberProduct(o);
    createUeberSubscription(o,ueberProduct);
    poolManager.refreshPools(o);
    Consumer consumer=createUeberConsumer(principal,o);
    List<Pool> ueberPool=poolCurator.listAvailableEntitlementPools(null,o,ueberProduct.getId(),null,false,false);
    return generateUeberCertificate(consumer,ueberPool);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + o.getKey(),e);
    throw new BadRequestException(i18n.tr("String_Node_Str",e));
  }
}

Fixed version (ground truth):
/** 
 * @return an EntitlementCertificate
 * @httpcode 400
 * @httpcode 404
 * @httpcode 200
 */
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public EntitlementCertificate createUeberCertificate(@Context Principal principal,@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey){
  Owner o=findOwner(ownerKey);
  if (o == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",ownerKey));
  }
  Consumer ueberConsumer=consumerCurator.findByName(o,UEBER_CERT_CONSUMER);
  if (ueberConsumer != null) {
    List<Entitlement> ueberEntitlement=entitlementCurator.listByConsumer(ueberConsumer);
    poolManager.regenerateCertificatesOf(ueberEntitlement.get(0),true);
    return entitlementCertCurator.listForConsumer(ueberConsumer).get(0);
  }
  try {
    Product ueberProduct=createUeberProduct(o);
    createUeberSubscription(o,ueberProduct);
    poolManager.refreshPools(o);
    Consumer consumer=createUeberConsumer(principal,o);
    List<Pool> ueberPool=poolCurator.listAvailableEntitlementPools(null,o,ueberProduct.getId(),null,false,false);
    return generateUeberCertificate(consumer,ueberPool);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + o.getKey(),e);
    throw new BadRequestException(i18n.tr("String_Node_Str",e));
  }
}
Program: 49524
Project: 49524
Buggy source:
@Test public void testUeberConsumerIsCreated() throws Exception {
  or.createUeberCertificate(principal,owner.getKey());
  assertNotNull(consumerCurator.findByName("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testUeberConsumerIsCreated() throws Exception {
  or.createUeberCertificate(principal,owner.getKey());
  assertNotNull(consumerCurator.findByName(owner,"String_Node_Str"));
}
Program: 49525
Project: 49525
Buggy source:
@Test public void testUeberEntitlementIsGenerated() throws Exception {
  or.createUeberCertificate(principal,owner.getKey());
  Consumer c=consumerCurator.findByName("String_Node_Str");
  assertTrue(poolCurator.listByConsumer(c).size() == 1);
}

Fixed version (ground truth):
@Test public void testUeberEntitlementIsGenerated() throws Exception {
  or.createUeberCertificate(principal,owner.getKey());
  Consumer c=consumerCurator.findByName(owner,"String_Node_Str");
  assertTrue(poolCurator.listByConsumer(c).size() == 1);
}
Program: 49526
Project: 49526
Buggy source:
@Test(expected=NotFoundException.class) public void certificateRetrievalRaisesExceptionIfNoCertificateWasGenerated() throws Exception {
  Owner anotherOwner=ownerCurator.create(new Owner(OWNER_NAME + "String_Node_Str"));
  or.getUeberCertificate(principal,anotherOwner.getKey());
}

Fixed version (ground truth):
@Test(expected=NotFoundException.class) public void certificateRetrievalRaisesExceptionIfNoCertificateWasGenerated() throws Exception {
  or.createUeberCertificate(principal,owner.getKey());
  Owner anotherOwner=ownerCurator.create(new Owner(OWNER_NAME + "String_Node_Str"));
  or.getUeberCertificate(principal,anotherOwner.getKey());
}
Program: 49527
Project: 49527
Buggy source:
/** 
 * Create a pool for a product and limit it to consumers a particular user has registered.
 * @param productId Label of the product the pool is for.
 * @param quantity Number of entitlements for this pool, also accepts "unlimited".
 */
public void createParentConsumerRestrictedPool(String productId,Pool pool,String quantity,Map<String,String> newPoolAttributes){
  Pool consumerSpecificPool=createPool(productId,pool.getOwner(),quantity,pool.getStartDate(),pool.getEndDate(),pool.getContractNumber(),pool.getAccountNumber(),pool.getProvidedProducts());
  consumerSpecificPool.setRestrictedToParentConsumer(this.sourceEntitlement.getConsumer().getUuid());
  consumerSpecificPool.setSubscriptionId(pool.getSubscriptionId());
  for (  String key : newPoolAttributes.keySet()) {
    PoolAttribute pa=new PoolAttribute(key,newPoolAttributes.get(key));
    consumerSpecificPool.addAttribute(pa);
  }
  poolManager.createPool(consumerSpecificPool);
}

Fixed version (ground truth):
/** 
 * Create a pool for a product and limit it to consumers a particular user has registered.
 * @param productId Label of the product the pool is for.
 * @param quantity Number of entitlements for this pool, also accepts "unlimited".
 */
public void createParentConsumerRestrictedPool(String productId,Pool pool,String quantity,Map<String,String> newPoolAttributes){
  Pool consumerSpecificPool=createPool(productId,pool.getOwner(),quantity,pool.getStartDate(),pool.getEndDate(),pool.getContractNumber(),pool.getAccountNumber(),pool.getProvidedProducts());
  consumerSpecificPool.setRestrictedToParentConsumer(this.sourceEntitlement.getConsumer().getUuid());
  consumerSpecificPool.setAttribute("String_Node_Str","String_Node_Str");
  consumerSpecificPool.setSubscriptionId(pool.getSubscriptionId());
  for (  String key : newPoolAttributes.keySet()) {
    PoolAttribute pa=new PoolAttribute(key,newPoolAttributes.get(key));
    consumerSpecificPool.addAttribute(pa);
  }
  poolManager.createPool(consumerSpecificPool);
}
Program: 49529
Project: 49529
Buggy source:
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public List<Role> getUserRoles(@PathParam("String_Node_Str") @Verify(User.class) String username){
  List<Role> roles=userService.getRoles(username);
  User myUser=userService.findByLogin(username);
  Set<User> s=new HashSet<User>();
  s.add(myUser);
  for (  Role r : roles) {
    r.setUsers(s);
  }
  return roles;
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public List<Role> getUserRoles(@PathParam("String_Node_Str") @Verify(User.class) String username){
  User myUser=userService.findByLogin(username);
  List<Role> roles=new LinkedList<Role>(myUser.getRoles());
  Set<User> s=new HashSet<User>();
  s.add(myUser);
  for (  Role r : roles) {
    r.setUsers(s);
  }
  return roles;
}
Program: 49530
Project: 49530
Buggy source:
/** 
 * Return the entitlement pools for the owner of the given id.
 * @param ownerKey id of the owner whose entitlement pools are sought.
 * @return the entitlement pools for the owner of the given id.
 */
@GET @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public List<Pool> getPools(@PathParam("String_Node_Str") @Verify(value=Owner.class,require=Access.READ_POOLS) String ownerKey,@QueryParam("String_Node_Str") String consumerUuid,@QueryParam("String_Node_Str") String productId,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") boolean listAll,@QueryParam("String_Node_Str") String activeOn){
  Owner owner=findOwner(ownerKey);
  Date activeOnDate=new Date();
  if (activeOn != null) {
    activeOnDate=parseDateString(activeOn);
  }
  Consumer c=null;
  if (consumerUuid != null) {
    c=consumerCurator.findByUuid(consumerUuid);
    if (c == null) {
      throw new NotFoundException(i18n.tr("String_Node_Str",consumerUuid));
    }
    if (c.getOwner().getId().equals(owner.getId())) {
      throw new BadRequestException("String_Node_Str");
    }
  }
  return poolCurator.listAvailableEntitlementPools(c,owner,productId,activeOnDate,true,listAll);
}

Fixed version (ground truth):
/** 
 * Return the entitlement pools for the owner of the given id.
 * @param ownerKey id of the owner whose entitlement pools are sought.
 * @return the entitlement pools for the owner of the given id.
 */
@GET @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public List<Pool> getPools(@PathParam("String_Node_Str") @Verify(value=Owner.class,require=Access.READ_POOLS) String ownerKey,@QueryParam("String_Node_Str") String consumerUuid,@QueryParam("String_Node_Str") String productId,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") boolean listAll,@QueryParam("String_Node_Str") String activeOn){
  Owner owner=findOwner(ownerKey);
  Date activeOnDate=new Date();
  if (activeOn != null) {
    activeOnDate=parseDateString(activeOn);
  }
  Consumer c=null;
  if (consumerUuid != null) {
    c=consumerCurator.findByUuid(consumerUuid);
    if (c == null) {
      throw new NotFoundException(i18n.tr("String_Node_Str",consumerUuid));
    }
    if (!c.getOwner().getId().equals(owner.getId())) {
      throw new BadRequestException("String_Node_Str");
    }
  }
  return poolCurator.listAvailableEntitlementPools(c,owner,productId,activeOnDate,true,listAll);
}
Program: 49531
Project: 49531
Buggy source:
@Override public Object lookup(String key){
  return poolCurator.find(key);
}

Fixed version (ground truth):
@Override public Object lookup(String key){
  if (poolCurator == null) {
    poolCurator=injector.getInstance(PoolCurator.class);
  }
  return poolCurator.find(key);
}
Program: 49532
Project: 49532
Buggy source:
@Override public boolean canAccessTarget(Entitlement target,Access action){
  return target.getOwner().getKey().equals(consumer.getOwner().getKey());
}

Fixed version (ground truth):
@Override public boolean canAccessTarget(Entitlement target,Access action){
  return target.getConsumer().getUuid().equals(consumer.getUuid());
}
Program: 49533
Project: 49533
Buggy source:
@Test public void testGetUsers(){
  String ownerName=owner.getKey();
  User user=new User();
  user.setUsername("String_Node_Str");
  user.setPassword("String_Node_Str");
  userCurator.create(user);
  Role role=new Role();
  role.addUser(user);
  role.addPermission(new Permission(owner,Verb.OWNER_ADMIN));
  user.addRole(role);
  roleCurator.create(role);
  User user2=new User();
  user2.setUsername("String_Node_Str");
  user2.setPassword("String_Node_Str");
  user2.addRole(role);
  userCurator.create(user2);
  roleCurator.merge(role);
  List<User> users=ownerResource.getUsers(ownerName);
  assertEquals(users.size(),2);
  assertEquals(users.get(1),user2);
}

Fixed version (ground truth):
@Test public void testGetUsers(){
  String ownerName=owner.getKey();
  User user=new User();
  user.setUsername("String_Node_Str");
  user.setPassword("String_Node_Str");
  userCurator.create(user);
  Role role=new Role();
  role.addUser(user);
  role.addPermission(new Permission(owner,Verb.OWNER_ADMIN));
  user.addRole(role);
  roleCurator.create(role);
  User user2=new User();
  user2.setUsername("String_Node_Str");
  user2.setPassword("String_Node_Str");
  user2.addRole(role);
  userCurator.create(user2);
  roleCurator.merge(role);
  List<User> users=ownerResource.getUsers(ownerName);
  assertEquals(users.size(),2);
  assertTrue(users.contains(user2));
}
Program: 49534
Project: 49534
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  Principal currentUser=this.principalProvider.get();
  log.debug("String_Node_Str");
  EnumSet<Verb> allowedRoles=EnumSet.noneOf(Verb.class);
  allowedRoles.add(Verb.SUPER_ADMIN);
  log.debug(invocation.getClass().getName());
  log.debug(invocation.getClass().getAnnotations().length);
  AllowRoles annotation=invocation.getMethod().getAnnotation(AllowRoles.class);
  log.debug("String_Node_Str" + annotation);
  if (annotation != null) {
    for (    Verb allowed : annotation.roles()) {
      log.debug("String_Node_Str" + allowed);
      allowedRoles.add(allowed);
    }
  }
  boolean foundRole=false;
  for (  Verb allowed : allowedRoles) {
    if (hasRole(currentUser,allowed)) {
      foundRole=true;
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + currentUser + "String_Node_Str"+ allowed);
      }
      break;
    }
  }
  if (!foundRole) {
    log.warn("String_Node_Str" + currentUser + "String_Node_Str"+ invocation.getMethod().getName());
    I18n i18n=this.i18nProvider.get();
    String error="String_Node_Str";
    throw new ForbiddenException(i18n.tr(error));
  }
  return invocation.proceed();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public Object invoke(MethodInvocation invocation) throws Throwable {
  Principal currentUser=this.principalProvider.get();
  log.debug("String_Node_Str");
  EnumSet<Verb> allowedRoles=EnumSet.of(Verb.SUPER_ADMIN);
  AllowRoles annotation=invocation.getMethod().getAnnotation(AllowRoles.class);
  log.debug("String_Node_Str" + annotation);
  if (annotation != null) {
    for (    Verb allowed : annotation.roles()) {
      log.debug("String_Node_Str" + allowed);
      allowedRoles.add(allowed);
    }
  }
  boolean foundRole=false;
  for (  Verb allowed : allowedRoles) {
    if (hasRole(currentUser,allowed)) {
      foundRole=true;
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + currentUser + "String_Node_Str"+ allowed);
      }
      break;
    }
  }
  if (!foundRole) {
    log.warn("String_Node_Str" + currentUser + "String_Node_Str"+ invocation.getMethod().getName());
    I18n i18n=this.i18nProvider.get();
    String error="String_Node_Str";
    throw new ForbiddenException(i18n.tr(error));
  }
  return invocation.proceed();
}
Program: 49535
Project: 49535
Buggy source:
public static Principal createPrincipal(String username,Owner owner,Verb role){
  List<Verb> roles=new LinkedList<Verb>();
  roles.add(role);
  Principal ownerAdmin=new UserPrincipal(username,Arrays.asList(new Permission[]{new Permission(owner,Verb.OWNER_ADMIN)}));
  return ownerAdmin;
}

Fixed version (ground truth):
public static Principal createPrincipal(String username,Owner owner,Verb role){
  return new UserPrincipal(username,Arrays.asList(new Permission[]{new Permission(owner,role)}));
}
Program: 49536
Project: 49536
Buggy source:
private Consumer createConsumer(String consumerName){
  Consumer consumer=new Consumer(consumerName,null,null,system);
  Principal principal=new UserPrincipal(USER,null,null);
  return this.resource.create(consumer,principal,USER,null);
}

Fixed version (ground truth):
private Consumer createConsumer(String consumerName){
  Consumer consumer=new Consumer(consumerName,null,null,system);
  Principal principal=new UserPrincipal(USER,null);
  return this.resource.create(consumer,principal,USER,null);
}
Program: 49537
Project: 49537
Buggy source:
/** 
 * Valid credentials are given - checks if the correct principal is created.
 * @throws Exception
 */
@Test public void correctPrincipal() throws Exception {
  Owner owner=new Owner("String_Node_Str","String_Node_Str");
  List<Owner> owners=Arrays.asList(new Owner[]{owner});
  setUserAndPassword("String_Node_Str","String_Node_Str");
  when(userService.validateUser("String_Node_Str","String_Node_Str")).thenReturn(true);
  when(userService.getOwners("String_Node_Str")).thenReturn(owners);
  when(ownerCurator.lookupByKey("String_Node_Str")).thenReturn(owner);
  UserPrincipal expected=new UserPrincipal("String_Node_Str",owners,null);
  assertEquals(expected,this.auth.getPrincipal(request));
}

Fixed version (ground truth):
/** 
 * Valid credentials are given - checks if the correct principal is created.
 * @throws Exception
 */
@Test public void correctPrincipal() throws Exception {
  Owner owner=new Owner("String_Node_Str","String_Node_Str");
  setUserAndPassword("String_Node_Str","String_Node_Str");
  when(userService.validateUser("String_Node_Str","String_Node_Str")).thenReturn(true);
  when(ownerCurator.lookupByKey("String_Node_Str")).thenReturn(owner);
  List<Permission> permissions=Arrays.asList(new Permission[]{new Permission(owner,EnumSet.of(Role.OWNER_ADMIN))});
  UserPrincipal expected=new UserPrincipal("String_Node_Str",permissions);
  assertEquals(expected,this.auth.getPrincipal(request));
}
Program: 49538
Project: 49538
Buggy source:
@Test public void existingJobMapPrincipal(){
  List<Owner> owners=new ArrayList<Owner>();
  owners.add(new Owner("String_Node_Str"));
  Principal principal=new UserPrincipal("String_Node_Str",owners,null);
  when(this.principalProvider.get()).thenReturn(principal);
  JobDetail detail=new JobDetail();
  JobDataMap map=new JobDataMap();
  map.put("String_Node_Str","String_Node_Str");
  detail.setJobDataMap(map);
  when(response.getEntity()).thenReturn(detail);
  this.interceptor.postProcess(response);
  Assert.assertSame(principal,detail.getJobDataMap().get(PinsetterJobListener.PRINCIPAL_KEY));
}

Fixed version (ground truth):
@Test public void existingJobMapPrincipal(){
  List<Permission> permissions=Arrays.asList(new Permission[]{new Permission(new Owner("String_Node_Str"),EnumSet.of(Role.OWNER_ADMIN))});
  Principal principal=new UserPrincipal("String_Node_Str",permissions);
  when(this.principalProvider.get()).thenReturn(principal);
  JobDetail detail=new JobDetail();
  JobDataMap map=new JobDataMap();
  map.put("String_Node_Str","String_Node_Str");
  detail.setJobDataMap(map);
  when(response.getEntity()).thenReturn(detail);
  this.interceptor.postProcess(response);
  Assert.assertSame(principal,detail.getJobDataMap().get(PinsetterJobListener.PRINCIPAL_KEY));
}
Program: 49539
Project: 49539
Buggy source:
@Test public void noJobMapPrincipal(){
  List<Owner> owners=new ArrayList<Owner>();
  owners.add(new Owner("String_Node_Str"));
  Principal principal=new UserPrincipal("String_Node_Str",owners,null);
  when(this.principalProvider.get()).thenReturn(principal);
  JobDetail detail=new JobDetail();
  when(response.getEntity()).thenReturn(detail);
  this.interceptor.postProcess(response);
  Assert.assertEquals(principal,detail.getJobDataMap().get(PinsetterJobListener.PRINCIPAL_KEY));
}

Fixed version (ground truth):
@Test public void noJobMapPrincipal(){
  List<Permission> permissions=Arrays.asList(new Permission[]{new Permission(new Owner("String_Node_Str"),EnumSet.of(Role.OWNER_ADMIN))});
  Principal principal=new UserPrincipal("String_Node_Str",permissions);
  when(this.principalProvider.get()).thenReturn(principal);
  JobDetail detail=new JobDetail();
  when(response.getEntity()).thenReturn(detail);
  this.interceptor.postProcess(response);
  Assert.assertEquals(principal,detail.getJobDataMap().get(PinsetterJobListener.PRINCIPAL_KEY));
}
Program: 49540
Project: 49540
Buggy source:
/** 
 * @param clientKeyPair
 * @param extensions
 * @return
 * @throws IOException
 * @throws CertificateParsingException
 */
DEREncodable getSubjectKeyIdentifier(KeyPair clientKeyPair,Set<X509ExtensionWrapper> extensions) throws CertificateParsingException, IOException ;

Fixed version (ground truth):
/** 
 * @param clientKeyPair
 * @param extensions
 * @return DER encoded subjet key identifier
 * @throws CertificateParsingException thrown if problem parsing cert
 * @throws IOException thrown if error reading cert
 */
DEREncodable getSubjectKeyIdentifier(KeyPair clientKeyPair,Set<X509ExtensionWrapper> extensions) throws CertificateParsingException, IOException ;
Program: 49543
Project: 49543
Buggy source:
@Test public void testLookupRuleFiltering(){
  Product p=new Product(CPU_LIMITED_PRODUCT,CPU_LIMITED_PRODUCT);
  p.addAttribute(new ProductAttribute(CPU_LIMITED_PRODUCT,"String_Node_Str"));
  productCurator.create(p);
  Pool pool=createPoolAndSub(owner,p,100L,TestUtil.createDate(2000,3,2),TestUtil.createDate(2050,3,2));
  poolCurator.create(pool);
  List<Pool> results=poolCurator.listByConsumer(consumer);
  assertEquals(0,results.size());
}

Fixed version (ground truth):
@Test public void testLookupRuleFiltering(){
  Product p=new Product(CPU_LIMITED_PRODUCT,CPU_LIMITED_PRODUCT);
  p.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  productCurator.create(p);
  Pool pool=createPoolAndSub(owner,p,100L,TestUtil.createDate(2000,3,2),TestUtil.createDate(2050,3,2));
  poolCurator.create(pool);
  consumer.setFact("String_Node_Str","String_Node_Str");
  List<Pool> results=poolCurator.listByConsumer(consumer);
  assertEquals(0,results.size());
}
Program: 49544
Project: 49544
Buggy source:
@Test public void concurrentCreationOfEntitlementsShouldWorkIfUnderMaxMemberLimit() throws Exception {
  Long numAvailEntitlements=2L;
  Product newProduct=TestUtil.createProduct();
  productCurator.create(newProduct);
  Pool consumerPool=createPoolAndSub(owner,newProduct,numAvailEntitlements,TestUtil.createDate(2009,11,30),TestUtil.createDate(2050,11,30));
  consumerPool=poolCurator.create(consumerPool);
  CandlepinPoolManager anotherEntitler=injector.getInstance(CandlepinPoolManager.class);
  anotherEntitler.entitleByProduct(consumer,newProduct.getId(),new Integer("String_Node_Str"));
  anotherEntitler.entitleByProduct(consumer,newProduct.getId(),new Integer("String_Node_Str"));
  assertFalse(poolCurator.find(consumerPool.getId()).entitlementsAvailable(1));
}

Fixed version (ground truth):
@Test public void concurrentCreationOfEntitlementsShouldWorkIfUnderMaxMemberLimit() throws Exception {
  Long numAvailEntitlements=2L;
  Product newProduct=TestUtil.createProduct();
  newProduct.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  productCurator.create(newProduct);
  Pool consumerPool=createPoolAndSub(owner,newProduct,numAvailEntitlements,TestUtil.createDate(2009,11,30),TestUtil.createDate(2050,11,30));
  consumerPool=poolCurator.create(consumerPool);
  CandlepinPoolManager anotherEntitler=injector.getInstance(CandlepinPoolManager.class);
  anotherEntitler.entitleByProduct(consumer,newProduct.getId(),new Integer("String_Node_Str"));
  anotherEntitler.entitleByProduct(consumer,newProduct.getId(),new Integer("String_Node_Str"));
  assertFalse(poolCurator.find(consumerPool.getId()).entitlementsAvailable(1));
}
Program: 49545
Project: 49545
Buggy source:
@Before public void setUp(){
  owner=createOwner();
  ownerCurator.create(owner);
  product=TestUtil.createProduct();
  productCurator.create(product);
  consumer=TestUtil.createConsumer(owner);
  consumer.setFact("String_Node_Str","String_Node_Str");
  consumerTypeCurator.create(consumer.getType());
  consumerCurator.create(consumer);
}

Fixed version (ground truth):
@Before public void setUp(){
  owner=createOwner();
  ownerCurator.create(owner);
  product=TestUtil.createProduct();
  productCurator.create(product);
  consumer=TestUtil.createConsumer(owner);
  consumer.setFact("String_Node_Str","String_Node_Str");
  consumer.setType(new ConsumerType("String_Node_Str"));
  consumerTypeCurator.create(consumer.getType());
  consumerCurator.create(consumer);
}
Program: 49546
Project: 49546
Buggy source:
@Override public List<UpdatedPool> updatePools(Subscription sub,List<Pool> existingPools){
  Map<String,Object> args=new HashMap<String,Object>();
  args.put("String_Node_Str",sub);
  args.put("String_Node_Str",existingPools);
  args.put("String_Node_Str",jsRules.getFlattenedAttributes(sub.getProduct(),null));
  args.put("String_Node_Str",new PoolHelper(this.poolManager,this.productAdapter,null));
  List<UpdatedPool> poolsUpdated=null;
  try {
    poolsUpdated=jsRules.invokeMethod("String_Node_Str",args);
  }
 catch (  NoSuchMethodException e) {
    log.error("String_Node_Str");
    log.error(e);
    throw new IseException("String_Node_Str");
  }
  return poolsUpdated;
}

Fixed version (ground truth):
@Override public List<UpdatedPool> updatePools(Subscription sub,List<Pool> existingPools){
  Map<String,Object> args=new HashMap<String,Object>();
  args.put("String_Node_Str",sub);
  args.put("String_Node_Str",existingPools);
  args.put("String_Node_Str",jsRules.getFlattenedAttributes(sub.getProduct(),null));
  args.put("String_Node_Str",log);
  args.put("String_Node_Str",new PoolHelper(this.poolManager,this.productAdapter,null));
  List<UpdatedPool> poolsUpdated=null;
  try {
    poolsUpdated=jsRules.invokeMethod("String_Node_Str",args);
  }
 catch (  NoSuchMethodException e) {
    log.error("String_Node_Str");
    log.error(e);
    throw new IseException("String_Node_Str");
  }
  return poolsUpdated;
}
Program: 49547
Project: 49547
Buggy source:
/** 
 * @param sub
 * @return the newly created Pool
 */
public Pool createPoolForSubscription(Subscription sub){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + sub.getId());
  }
  Long quantity=sub.getQuantity() * sub.getProduct().getMultiplier();
  Set<ProvidedProduct> providedProducts=new HashSet<ProvidedProduct>();
  for (  Product p : sub.getProvidedProducts()) {
    ProvidedProduct providedProduct=new ProvidedProduct(p.getId(),p.getName());
    providedProducts.add(providedProduct);
  }
  Pool newPool=new Pool(sub.getOwner(),sub.getProduct().getId(),providedProducts,quantity,sub.getStartDate(),sub.getEndDate(),sub.getContractNumber());
  newPool.setSubscriptionId(sub.getId());
  createPool(newPool);
  return newPool;
}

Fixed version (ground truth):
/** 
 * @param sub
 * @return the newly created Pool
 */
public Pool createPoolForSubscription(Subscription sub){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + sub.getId());
  }
  Long quantity=sub.getQuantity() * sub.getProduct().getMultiplier();
  Set<ProvidedProduct> providedProducts=new HashSet<ProvidedProduct>();
  Pool newPool=new Pool(sub.getOwner(),sub.getProduct().getId(),providedProducts,quantity,sub.getStartDate(),sub.getEndDate(),sub.getContractNumber());
  for (  Product p : sub.getProvidedProducts()) {
    ProvidedProduct providedProduct=new ProvidedProduct(p.getId(),p.getName());
    providedProduct.setPool(newPool);
    providedProducts.add(providedProduct);
  }
  createPool(newPool);
  return newPool;
}
Program: 49548
Project: 49548
Buggy source:
/** 
 * @return the pool
 */
public Pool getPool(){
  return pool;
}

Fixed version (ground truth):
/** 
 * @return the pool
 */
@XmlTransient public Pool getPool(){
  return pool;
}
Program: 49549
Project: 49549
Buggy source:
@Inject public PoolResource(PoolCurator poolCurator,ConsumerCurator consumerCurator,OwnerCurator ownerCurator,ProductServiceAdapter productServiceAdapter,I18n i18n,EventSink eventSink){
  this.poolCurator=poolCurator;
  this.consumerCurator=consumerCurator;
  this.ownerCurator=ownerCurator;
  this.productServiceAdapter=productServiceAdapter;
  this.i18n=i18n;
  this.eventSink=eventSink;
}

Fixed version (ground truth):
@Inject public PoolResource(PoolCurator poolCurator,ConsumerCurator consumerCurator,OwnerCurator ownerCurator,I18n i18n,EventSink eventSink){
  this.poolCurator=poolCurator;
  this.consumerCurator=consumerCurator;
  this.ownerCurator=ownerCurator;
  this.i18n=i18n;
  this.eventSink=eventSink;
}
Program: 49550
Project: 49550
Buggy source:
@POST @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Pool createPool(Pool pool){
  Owner owner=ownerCurator.find(pool.getOwner().getId());
  if (owner == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",pool.getOwner().getId()));
  }
  pool.setOwner(owner);
  for (  PoolAttribute attr : pool.getAttributes()) {
    attr.setPool(pool);
  }
  Pool toReturn=poolCurator.create(pool);
  if (toReturn != null) {
    eventSink.emitPoolCreated(toReturn);
    return toReturn;
  }
  throw new BadRequestException(i18n.tr("String_Node_Str",pool));
}

Fixed version (ground truth):
@POST @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Pool createPool(Pool pool){
  Owner owner=ownerCurator.find(pool.getOwner().getId());
  if (owner == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",pool.getOwner().getId()));
  }
  pool.setOwner(owner);
  Pool toReturn=poolCurator.create(pool);
  if (toReturn != null) {
    eventSink.emitPoolCreated(toReturn);
    return toReturn;
  }
  throw new BadRequestException(i18n.tr("String_Node_Str",pool));
}
Program: 49551
Project: 49551
Buggy source:
/** 
 * @param product
 * @return the newly created product, or the product that alreadyexists
 */
@POST @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @AllowRoles(roles={Role.SUPER_ADMIN}) public Product createProduct(Product product){
  for (  ProductAttribute attr : product.getAttributes()) {
    attr.setProduct(product);
  }
  return prodAdapter.createProduct(product);
}

Fixed version (ground truth):
/** 
 * @param product
 * @return the newly created product, or the product that alreadyexists
 */
@POST @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) @AllowRoles(roles={Role.SUPER_ADMIN}) public Product createProduct(Product product){
  return prodAdapter.createProduct(product);
}
Program: 49552
Project: 49552
Buggy source:
private Entitlement addEntitlement(Consumer consumer,Pool pool,Integer quantity) throws EntitlementRefusedException {
  PreEntHelper preHelper=enforcer.preEntitlement(consumer,pool,quantity);
  ValidationResult result=preHelper.getResult();
  if (!result.isSuccessful()) {
    log.warn("String_Node_Str" + result.getErrors().toString());
    throw new EntitlementRefusedException(result);
  }
  Entitlement e=new Entitlement(pool,consumer,new Date(),pool.getEndDate(),quantity);
  consumer.addEntitlement(e);
  if (preHelper.getGrantFreeEntitlement()) {
    log.info("String_Node_Str");
    e.setIsFree(Boolean.TRUE);
  }
 else {
    pool.bumpConsumed(quantity);
  }
  postEntHelper.init(e);
  enforcer.postEntitlement(consumer,postEntHelper,e);
  entitlementCurator.create(e);
  consumerCurator.update(consumer);
  Pool mergedPool=epCurator.merge(pool);
  generateEntitlementCertificate(consumer,mergedPool,e);
  return e;
}

Fixed version (ground truth):
private Entitlement addEntitlement(Consumer consumer,Pool pool,Integer quantity) throws EntitlementRefusedException {
  PreEntHelper preHelper=enforcer.preEntitlement(consumer,pool,quantity);
  ValidationResult result=preHelper.getResult();
  if (!result.isSuccessful()) {
    log.warn("String_Node_Str" + result.getErrors().toString());
    throw new EntitlementRefusedException(result);
  }
  Entitlement e=new Entitlement(pool,consumer,new Date(),pool.getEndDate(),quantity);
  consumer.addEntitlement(e);
  pool.getEntitlements().add(e);
  if (preHelper.getGrantFreeEntitlement()) {
    log.info("String_Node_Str");
    e.setIsFree(Boolean.TRUE);
  }
 else {
    pool.bumpConsumed(quantity);
  }
  postEntHelper.init(e);
  enforcer.postEntitlement(consumer,postEntHelper,e);
  entitlementCurator.create(e);
  consumerCurator.update(consumer);
  Pool mergedPool=epCurator.merge(pool);
  generateEntitlementCertificate(consumer,mergedPool,e);
  return e;
}
Program: 49553
Project: 49553
Buggy source:
@SuppressWarnings("String_Node_Str") @Transactional public void delete(Entitlement entity){
  Entitlement toDelete=find(entity.getId());
  log.debug("String_Node_Str" + toDelete);
  log.debug("String_Node_Str" + toDelete.getCertificates().size());
  for (  EntitlementCertificate cert : toDelete.getCertificates()) {
    currentSession().delete(cert);
  }
  toDelete.getCertificates().clear();
  List<Pool> pools=currentSession().createCriteria(Pool.class).add(Restrictions.eq("String_Node_Str",entity)).list();
  for (  Pool pool : pools) {
    pool.setSourceEntitlement(null);
    currentSession().merge(pool);
  }
  currentSession().delete(toDelete);
  flush();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Transactional public void delete(Entitlement entity){
  Entitlement toDelete=find(entity.getId());
  log.debug("String_Node_Str" + toDelete);
  log.debug("String_Node_Str" + toDelete.getCertificates().size());
  for (  EntitlementCertificate cert : toDelete.getCertificates()) {
    currentSession().delete(cert);
  }
  toDelete.getCertificates().clear();
  List<Pool> pools=currentSession().createCriteria(Pool.class).add(Restrictions.eq("String_Node_Str",entity)).list();
  for (  Pool pool : pools) {
    pool.setSourceEntitlement(null);
    currentSession().merge(pool);
  }
  toDelete.getPool().getEntitlements().remove(toDelete);
  currentSession().delete(toDelete);
  flush();
}
Program: 49554
Project: 49554
Buggy source:
/** 
 * Gets the entitlements for this instance.
 * @return The entitlements.
 */
public Set<Entitlement> getEntitlements(){
  return this.entitlements;
}

Fixed version (ground truth):
/** 
 * Gets the entitlements for this instance.
 * @return The entitlements.
 */
@XmlTransient public Set<Entitlement> getEntitlements(){
  return this.entitlements;
}
Program: 49555
Project: 49555
Buggy source:
@Test public void createEntitlementShouldIncreaseNumberOfMembers() throws Exception {
  Long numAvailEntitlements=new Long(1);
  Product newProduct=TestUtil.createProduct();
  productCurator.create(newProduct);
  Pool consumerPool=createPoolAndSub(owner,newProduct,numAvailEntitlements,TestUtil.createDate(2009,11,30),TestUtil.createDate(2050,11,30));
  consumerPool=poolCurator.create(consumerPool);
  entitler.entitleByProduct(consumer,newProduct.getId(),new Integer("String_Node_Str"));
  assertFalse(poolCurator.find(consumerPool.getId()).entitlementsAvailable(new Integer(1)));
}

Fixed version (ground truth):
@Test public void createEntitlementShouldIncreaseNumberOfMembers() throws Exception {
  Long numAvailEntitlements=new Long(1);
  Product newProduct=TestUtil.createProduct();
  productCurator.create(newProduct);
  Pool consumerPool=createPoolAndSub(owner,newProduct,numAvailEntitlements,TestUtil.createDate(2009,11,30),TestUtil.createDate(2050,11,30));
  consumerPool=poolCurator.create(consumerPool);
  entitler.entitleByProduct(consumer,newProduct.getId(),new Integer("String_Node_Str"));
  consumerPool=poolCurator.find(consumerPool.getId());
  assertFalse(consumerPool.entitlementsAvailable(new Integer(1)));
  assertEquals(1,consumerPool.getEntitlements().size());
}
Program: 49556
Project: 49556
Buggy source:
/** 
 * Gets the serial.
 * @return the serial
 */
@JsonIgnore public BigInteger getSerial(){
  if (this.serial != null) {
    return serial;
  }
  return this.getX509Certificate().getSerialNumber();
}

Fixed version (ground truth):
/** 
 * Gets the serial.
 * @return the serial
 */
@JsonIgnore public BigInteger getSerial(){
  return this.getX509Certificate().getSerialNumber();
}
Program: 49558
Project: 49558
Buggy source:
public static Product createProduct(){
  int random=randomInt();
  Product rhel=new Product("String_Node_Str" + random,"String_Node_Str" + random);
  rhel.setId("String_Node_Str" + random);
  ProductAttribute a1=new ProductAttribute("String_Node_Str","String_Node_Str");
  a1.setId(new Long(1001));
  rhel.addAttribute(a1);
  ProductAttribute a2=new ProductAttribute("String_Node_Str","String_Node_Str");
  a2.setId(new Long(1002));
  rhel.addAttribute(a2);
  return rhel;
}

Fixed version (ground truth):
public static Product createProduct(){
  int random=randomInt();
  Product rhel=new Product("String_Node_Str" + random,"String_Node_Str" + random);
  rhel.setId("String_Node_Str" + random);
  ProductAttribute a1=new ProductAttribute("String_Node_Str","String_Node_Str");
  rhel.addAttribute(a1);
  ProductAttribute a2=new ProductAttribute("String_Node_Str","String_Node_Str");
  rhel.addAttribute(a2);
  return rhel;
}
Program: 49559
Project: 49559
Buggy source:
@Test public void testRefreshPoolsWithRemovedSubscriptions(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Subscription sub=new Subscription(owner,prod,new HashSet<Product>(),2000L,TestUtil.createDate(2010,2,9),TestUtil.createDate(3000,2,9),TestUtil.createDate(2010,2,12));
  subCurator.create(sub);
  ownerResource.refreshEntitlementPools(owner.getKey());
  List<Pool> pools=poolCurator.listByOwnerAndProduct(owner,prod.getId());
  assertEquals(1,pools.size());
  Pool newPool=pools.get(0);
  subCurator.delete(sub);
  ownerResource.refreshEntitlementPools(owner.getKey());
  assertEquals(1,pools.size());
  newPool=pools.get(0);
  assertFalse(newPool.isActive());
}

Fixed version (ground truth):
@Test public void testRefreshPoolsWithRemovedSubscriptions(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Subscription sub=new Subscription(owner,prod,new HashSet<Product>(),2000L,TestUtil.createDate(2010,2,9),TestUtil.createDate(3000,2,9),TestUtil.createDate(2010,2,12));
  subCurator.create(sub);
  ownerResource.refreshEntitlementPools(owner.getKey(),false);
  List<Pool> pools=poolCurator.listByOwnerAndProduct(owner,prod.getId());
  assertEquals(1,pools.size());
  Pool newPool=pools.get(0);
  subCurator.delete(sub);
  ownerResource.refreshEntitlementPools(owner.getKey(),false);
  assertEquals(1,pools.size());
  newPool=pools.get(0);
  assertFalse(newPool.isActive());
}
Program: 49560
Project: 49560
Buggy source:
@Test public void testRefreshMultiplePools(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Product prod2=TestUtil.createProduct();
  productCurator.create(prod2);
  Subscription sub=new Subscription(owner,prod,new HashSet<Product>(),2000L,TestUtil.createDate(2010,2,9),TestUtil.createDate(3000,2,9),TestUtil.createDate(2010,2,12));
  subCurator.create(sub);
  Subscription sub2=new Subscription(owner,prod2,new HashSet<Product>(),800L,TestUtil.createDate(2010,2,9),TestUtil.createDate(3000,2,9),TestUtil.createDate(2010,2,12));
  subCurator.create(sub2);
  ownerResource.refreshEntitlementPools(owner.getKey());
  List<Pool> pools=poolCurator.listByOwner(owner);
  assertEquals(2,pools.size());
}

Fixed version (ground truth):
@Test public void testRefreshMultiplePools(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Product prod2=TestUtil.createProduct();
  productCurator.create(prod2);
  Subscription sub=new Subscription(owner,prod,new HashSet<Product>(),2000L,TestUtil.createDate(2010,2,9),TestUtil.createDate(3000,2,9),TestUtil.createDate(2010,2,12));
  subCurator.create(sub);
  Subscription sub2=new Subscription(owner,prod2,new HashSet<Product>(),800L,TestUtil.createDate(2010,2,9),TestUtil.createDate(3000,2,9),TestUtil.createDate(2010,2,12));
  subCurator.create(sub2);
  ownerResource.refreshEntitlementPools(owner.getKey(),false);
  List<Pool> pools=poolCurator.listByOwner(owner);
  assertEquals(2,pools.size());
}