nus-yam/ex-repair huggingface dataset:
Program: 49224
Project: 49224
Buggy source:
public static boolean isSchedulable(JobCurator jobCurator,JobStatus status){
  long running=jobCurator.findNumRunningByClassAndTarget(status.getTargetId(),status.getJobClass());
  int throttle=conf.getInt(ConfigProperties.ENTITLER_JOB_THROTTLE);
  return running < throttle;
}

Fixed version (ground truth):
public static boolean isSchedulable(JobCurator jobCurator,JobStatus status){
  Class<? extends KingpinJob> jobClass;
  try {
    jobClass=(Class<? extends KingpinJob>)Class.forName(status.getJobClass());
  }
 catch (  ClassNotFoundException cnfe) {
    log.warn("String_Node_Str",status.getJobClass());
    return false;
  }
  long running=jobCurator.findNumRunningByClassAndTarget(status.getTargetId(),jobClass);
  int throttle=conf.getInt(ConfigProperties.ENTITLER_JOB_THROTTLE);
  return running < throttle;
}
Program: 49225
Project: 49225
Buggy source:
public static boolean isSchedulable(JobCurator jobCurator,JobStatus status){
  long running=jobCurator.findNumRunningByClassAndTarget(status.getTargetId(),status.getJobClass());
  return running == 0;
}

Fixed version (ground truth):
public static boolean isSchedulable(JobCurator jobCurator,JobStatus status){
  Class<? extends KingpinJob> jobClass;
  try {
    jobClass=(Class<? extends KingpinJob>)Class.forName(status.getJobClass());
  }
 catch (  ClassNotFoundException cnfe) {
    log.warn("String_Node_Str",status.getJobClass());
    return false;
  }
  long running=jobCurator.findNumRunningByClassAndTarget(status.getTargetId(),jobClass);
  return running == 0;
}
Program: 49226
Project: 49226
Buggy source:
@Override public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
  List<JobStatus> waitingJobs;
  try {
    waitingJobs=jobCurator.findWaitingJobs().list();
  }
 catch (  HibernateException e) {
    log.error("String_Node_Str",e);
    throw new JobExecutionException(e);
  }
  for (  JobStatus j : waitingJobs) {
    try {
      boolean schedule=(Boolean)j.getJobClass().getMethod("String_Node_Str",JobCurator.class,JobStatus.class).invoke(null,jobCurator,j);
      if (schedule) {
        log.debug("String_Node_Str" + j.getId());
        pinsetterKernel.addTrigger(j);
        j.setState(JobState.CREATED);
        jobCurator.merge(j);
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str" + j.getId(),e);
    }
  }
}

Fixed version (ground truth):
@Override public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
  List<JobStatus> waitingJobs;
  try {
    waitingJobs=jobCurator.findWaitingJobs().list();
  }
 catch (  HibernateException e) {
    log.error("String_Node_Str",e);
    throw new JobExecutionException(e);
  }
  for (  JobStatus j : waitingJobs) {
    try {
      Class jobClass=Class.forName(j.getJobClass());
      boolean schedule=(Boolean)jobClass.getMethod("String_Node_Str",JobCurator.class,JobStatus.class).invoke(null,jobCurator,j);
      if (schedule) {
        log.debug("String_Node_Str" + j.getId());
        pinsetterKernel.addTrigger(j);
        j.setState(JobState.CREATED);
        jobCurator.merge(j);
      }
    }
 catch (    ClassNotFoundException cnfe) {
      log.warn("String_Node_Str" + "String_Node_Str",j.getJobClass());
      j.setState(JobState.CANCELED);
      j.setResult("String_Node_Str");
      jobCurator.merge(j);
    }
catch (    Exception e) {
      log.error("String_Node_Str" + j.getId(),e);
    }
  }
}
Program: 49227
Project: 49227
Buggy source:
@Before public void init(){
  MockitoAnnotations.initMocks(this);
  unpauseJob=new UnpauseJob(j,pk);
}

Fixed version (ground truth):
@Before public void init(){
  MockitoAnnotations.initMocks(this);
  unpauseJob=new UnpauseJob(jobCurator,pk);
}
Program: 49228
Project: 49228
Buggy source:
@Test public void noUnPausesTest() throws JobExecutionException {
  when(j.findWaitingJobs()).thenReturn(new EmptyCandlepinQuery<JobStatus>());
  unpauseJob.execute(ctx);
  try {
    verify(pk,never()).addTrigger(any(JobStatus.class));
  }
 catch (  SchedulerException e) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void noUnPausesTest() throws JobExecutionException {
  when(jobCurator.findWaitingJobs()).thenReturn(new EmptyCandlepinQuery<JobStatus>());
  unpauseJob.execute(ctx);
  try {
    verify(pk,never()).addTrigger(any(JobStatus.class));
  }
 catch (  SchedulerException e) {
    fail("String_Node_Str");
  }
}
Program: 49229
Project: 49229
Buggy source:
@Test public void unPauseTest() throws JobExecutionException, PinsetterException {
  JobDetail jd=newJob(KingpinJob.class).withIdentity("String_Node_Str","String_Node_Str").build();
  JobStatus js=new JobStatus(jd,true);
  List<JobStatus> jl=new ArrayList<JobStatus>();
  jl.add(js);
  CandlepinQuery query=mock(CandlepinQuery.class);
  when(query.list()).thenReturn(jl);
  when(j.findWaitingJobs()).thenReturn(query);
  unpauseJob.execute(ctx);
  try {
    verify(pk,atLeastOnce()).addTrigger(js);
  }
 catch (  SchedulerException e) {
    fail("String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void unPauseTest() throws JobExecutionException, PinsetterException {
  JobDetail jd=newJob(KingpinJob.class).withIdentity("String_Node_Str","String_Node_Str").build();
  JobStatus js=new JobStatus(jd,true);
  List<JobStatus> jl=new ArrayList<JobStatus>();
  jl.add(js);
  CandlepinQuery query=mock(CandlepinQuery.class);
  when(query.list()).thenReturn(jl);
  when(jobCurator.findWaitingJobs()).thenReturn(query);
  unpauseJob.execute(ctx);
  try {
    verify(pk,atLeastOnce()).addTrigger(js);
  }
 catch (  SchedulerException e) {
    fail("String_Node_Str");
  }
}
Program: 49230
Project: 49230
Buggy source:
@ApiOperation(notes="String_Node_Str",value="String_Node_Str",response=Pool.class,responseContainer="String_Node_Str") @ApiResponses({@ApiResponse(code=400,message="String_Node_Str")}) @GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Iterator<Pool> getActivationKeyPools(@PathParam("String_Node_Str") String activationKeyId){
  ActivationKey key=activationKeyCurator.verifyAndLookupKey(activationKeyId);
  return new TransformedIterator<ActivationKeyPool,Pool>(key.getPools().iterator(),new ElementTransformer<ActivationKeyPool,Pool>(){
    @Override public Pool transform(    ActivationKeyPool akp){
      return akp.getPool();
    }
  }
);
}

Fixed version (ground truth):
@ApiOperation(notes="String_Node_Str",value="String_Node_Str",response=Pool.class,responseContainer="String_Node_Str") @ApiResponses({@ApiResponse(code=400,message="String_Node_Str")}) @GET @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) public Iterator<Pool> getActivationKeyPools(@PathParam("String_Node_Str") @Verify(ActivationKey.class) String activationKeyId){
  ActivationKey key=activationKeyCurator.verifyAndLookupKey(activationKeyId);
  return new TransformedIterator<ActivationKeyPool,Pool>(key.getPools().iterator(),new ElementTransformer<ActivationKeyPool,Pool>(){
    @Override public Pool transform(    ActivationKeyPool akp){
      return akp.getPool();
    }
  }
);
}
Program: 49231
Project: 49231
Buggy source:
/** 
 * Cache for fully hydrated Product entities
 * @return Cache for Status entity
 */
public Cache<String,Product> getProductCache(){
  return cacheManager.getCache(CacheContextListener.CACHE_PRODUCT_FULL);
}

Fixed version (ground truth):
/** 
 * Cache for fully hydrated Product entities
 * @return Cache for Status entity
 */
public Cache<String,Product> getProductCache(){
  return cacheManager.getCache(CACHE_PRODUCT_FULL);
}
Program: 49232
Project: 49232
Buggy source:
@Inject public CandlepinCache(CacheManager cacheManager){
  this.cacheManager=cacheManager;
}

Fixed version (ground truth):
@Inject public CandlepinCache(CacheManager cacheManager){
  this.cacheManager=cacheManager;
  this.statusCache=new StatusCache();
}
Program: 49233
Project: 49233
Buggy source:
/** 
 * Retrieves Candlepin Status cache. This cache will be used only to cache status resource responses using single key STATUS_KEY
 * @return Cache for Status entity
 */
public Cache<String,Status> getStatusCache(){
  return cacheManager.getCache(CacheContextListener.CACHE_STATUS,String.class,Status.class);
}

Fixed version (ground truth):
/** 
 * Retrieves Candlepin Status cache. This cache will be used only to cache status resource responses.
 * @return StatusCache for Status entity
 */
public StatusCache getStatusCache(){
  return this.statusCache;
}
Program: 49235
Project: 49235
Buggy source:
/** 
 * Retrieves the Status of the System <p> <pre> { "result" : true, "version" : "0.9.10", "rulesVersion" : "5.8", "release" : "1", "standalone" : true, "timeUTC" : [date], "managerCapabilities" : [ "cores", "ram", "instance_multiplier" ], "rulesSource" : "DEFAULT" } </pre> <p> Status to see if a server is up and running
 * @return a Status object
 * @httpcode 200
 */
@GET @ApiOperation(value="String_Node_Str",notes="String_Node_Str",authorizations={}) @Produces({MediaType.APPLICATION_JSON}) @SecurityHole(noAuth=true,anon=true) public Status status(){
  Cache<String,Status> statusCache=candlepinCache.getStatusCache();
  Status cached=statusCache.get(CandlepinCache.STATUS_KEY);
  if (cached != null) {
    return cached;
  }
  boolean good=true;
  try {
    rulesCurator.getUpdatedFromDB();
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    good=false;
  }
  CandlepinModeChange modeChange=modeManager.getLastCandlepinModeChange();
  if (modeChange.getMode() != Mode.NORMAL) {
    good=false;
  }
  Status status=new Status(good,version,release,standalone,jsProvider.getRulesVersion(),jsProvider.getRulesSource(),modeChange.getMode(),modeChange.getReason(),modeChange.getChangeTime());
  statusCache.put(CandlepinCache.STATUS_KEY,status);
  return status;
}

Fixed version (ground truth):
/** 
 * Retrieves the Status of the System <p> <pre> { "result" : true, "version" : "0.9.10", "rulesVersion" : "5.8", "release" : "1", "standalone" : true, "timeUTC" : [date], "managerCapabilities" : [ "cores", "ram", "instance_multiplier" ], "rulesSource" : "DEFAULT" } </pre> <p> Status to see if a server is up and running
 * @return a Status object
 * @httpcode 200
 */
@GET @ApiOperation(value="String_Node_Str",notes="String_Node_Str",authorizations={}) @Produces({MediaType.APPLICATION_JSON}) @SecurityHole(noAuth=true,anon=true) public Status status(){
  StatusCache statusCache=candlepinCache.getStatusCache();
  Status cached=statusCache.getStatus();
  if (cached != null) {
    return cached;
  }
  boolean good=true;
  try {
    rulesCurator.getUpdatedFromDB();
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    good=false;
  }
  CandlepinModeChange modeChange=modeManager.getLastCandlepinModeChange();
  if (modeChange.getMode() != Mode.NORMAL) {
    good=false;
  }
  Status status=new Status(good,version,release,standalone,jsProvider.getRulesVersion(),jsProvider.getRulesSource(),modeChange.getMode(),modeChange.getReason(),modeChange.getChangeTime());
  statusCache.setStatus(status);
  return status;
}
Program: 49237
Project: 49237
Buggy source:
@Inject public CdnManager(CdnCurator cdnCurator,CertificateSerialCurator certSerialCurator){
  this.cdnCurator=cdnCurator;
  this.certSerialCurator=certSerialCurator;
}

Fixed version (ground truth):
@Inject public CdnManager(CdnCurator cdnCurator,PoolCurator poolCurator,CertificateSerialCurator certSerialCurator){
  this.cdnCurator=cdnCurator;
  this.certSerialCurator=certSerialCurator;
  this.poolCurator=poolCurator;
}
Program: 49238
Project: 49238
Buggy source:
/** 
 * Deletes the specified   {@link Cdn}.
 * @param cdn the cdn to delete.
 */
@Transactional public void deleteCdn(Cdn cdn){
  cdnCurator.delete(cdn);
}

Fixed version (ground truth):
/** 
 * Deletes the specified   {@link Cdn}.
 * @param cdn the cdn to delete.
 */
@Transactional public void deleteCdn(Cdn cdn){
  poolCurator.removeCdn(cdn);
  cdnCurator.delete(cdn);
}
Program: 49239
Project: 49239
Buggy source:
/** 
 * Fetches a collection of content used by the given products
 * @param products The products for which to fetch content
 * @return A collection of content used by the specified products
 */
@SuppressWarnings("String_Node_Str") public CandlepinQuery<Content> getContentByProducts(Collection<Product> products){
  if (products != null && !products.isEmpty()) {
    Session session=this.currentSession();
    List<String> uuids=session.createCriteria(ProductContent.class).add(CPRestrictions.in("String_Node_Str",products)).setProjection(Projections.distinct(Projections.property("String_Node_Str"))).list();
    if (uuids != null && !uuids.isEmpty()) {
      DetachedCriteria criteria=this.createSecureDetachedCriteria().add(CPRestrictions.in("String_Node_Str",uuids));
      return this.cpQueryFactory.<Content>buildQuery(session,criteria);
    }
  }
  return this.cpQueryFactory.<Content>buildQuery();
}

Fixed version (ground truth):
/** 
 * Fetches a collection of content used by the given products
 * @param products The products for which to fetch content
 * @return A collection of content used by the specified products
 */
@SuppressWarnings("String_Node_Str") public CandlepinQuery<Content> getContentByProducts(Collection<Product> products){
  Collection<String> uuids=new HashSet<String>();
  for (  Product product : products) {
    uuids.add(product.getUuid());
  }
  return this.getContentByProductUuids(uuids);
}
Program: 49242
Project: 49242
Buggy source:
/** 
 * @param consumer
 * @param principal
 * @param userName
 * @return a String object
 */
private void checkConsumerName(Consumer consumer){
  if (consumer.getName() != null) {
    if (consumer.getName().indexOf('#') == 0) {
      throw new BadRequestException(i18n.tr("String_Node_Str"));
    }
    int max=Consumer.MAX_LENGTH_OF_CONSUMER_NAME;
    if (consumer.getName().length() > max) {
      String m="String_Node_Str";
      throw new BadRequestException(i18n.tr(m,Integer.toString(max)));
    }
  }
}

Fixed version (ground truth):
/** 
 * @param consumer
 * @param principal
 * @param userName
 * @return a String object
 */
private void checkConsumerName(Consumer consumer){
  if (consumer.getName() != null) {
    if (consumer.getName().indexOf('#') == 0) {
      throw new BadRequestException(i18n.tr("String_Node_Str"));
    }
    int max=Consumer.MAX_LENGTH_OF_CONSUMER_NAME;
    if (consumer.getName().length() > max) {
      String m="String_Node_Str";
      throw new BadRequestException(i18n.tr(m,Integer.toString(max + 1)));
    }
  }
}
Program: 49243
Project: 49243
Buggy source:
@Test public void testCreateConsumerShouldFailOnMaxLengthOfName(){
  thrown.expect(BadRequestException.class);
  int max=Consumer.MAX_LENGTH_OF_CONSUMER_NAME;
  String m=String.format("String_Node_Str" + "String_Node_Str",max);
  thrown.expectMessage(m);
  Consumer c=mock(Consumer.class);
  Owner o=mock(Owner.class);
  UserPrincipal up=mock(UserPrincipal.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  ConsumerType cType=new ConsumerType(ConsumerTypeEnum.SYSTEM);
  ConsumerResource consumerResource=createConsumerResource(oc);
  String ownerKey="String_Node_Str";
  when(oc.lookupByKey(eq(ownerKey))).thenReturn(o);
  when(o.getKey()).thenReturn(ownerKey);
  when(c.getType()).thenReturn(cType);
  String s=RandomStringUtils.randomAlphanumeric(max + 1);
  when(c.getName()).thenReturn(s);
  when(up.canAccess(eq(o),eq(SubResource.CONSUMERS),eq(Access.CREATE))).thenReturn(true);
  consumerResource.create(c,up,null,ownerKey,null,false);
}

Fixed version (ground truth):
@Test public void testCreateConsumerShouldFailOnMaxLengthOfName(){
  thrown.expect(BadRequestException.class);
  thrown.expectMessage(String.format("String_Node_Str" + "String_Node_Str",Consumer.MAX_LENGTH_OF_CONSUMER_NAME + 1));
  Consumer c=mock(Consumer.class);
  Owner o=mock(Owner.class);
  UserPrincipal up=mock(UserPrincipal.class);
  OwnerCurator oc=mock(OwnerCurator.class);
  ConsumerType cType=new ConsumerType(ConsumerTypeEnum.SYSTEM);
  ConsumerResource consumerResource=createConsumerResource(oc);
  String ownerKey="String_Node_Str";
  when(oc.lookupByKey(eq(ownerKey))).thenReturn(o);
  when(o.getKey()).thenReturn(ownerKey);
  when(c.getType()).thenReturn(cType);
  String s=RandomStringUtils.randomAlphanumeric(Consumer.MAX_LENGTH_OF_CONSUMER_NAME + 1);
  when(c.getName()).thenReturn(s);
  when(up.canAccess(eq(o),eq(SubResource.CONSUMERS),eq(Access.CREATE))).thenReturn(true);
  consumerResource.create(c,up,null,ownerKey,null,false);
}
Program: 49246
Project: 49246
Buggy source:
/** 
 * Removes the specified products from the given owner. Products which are shared will have any references to the owner removed, while unshared products will be deleted entirely.
 * @param owner The owner from which to remove products
 * @param productUuids A collection of product UUIDs representing the products to remove from the owner
 * @throws IllegalArgumentException if owner is null
 * @throws IllegalStateException if any of the given products are still associated with one or more subscriptions
 */
public void removeProductsByUuids(Owner owner,Collection<String> productUuids){
  if (owner == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (productUuids != null && !productUuids.isEmpty()) {
    log.debug("String_Node_Str",owner,productUuids);
    this.ownerProductCurator.removeOwnerProductReferences(owner,productUuids);
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified products from the given owner. Products which are shared will have any references to the owner removed, while unshared products will be deleted entirely.
 * @param owner The owner from which to remove products
 * @param productUuids A collection of product UUIDs representing the products to remove from the owner
 * @throws IllegalArgumentException if owner is null
 * @throws IllegalStateException if any of the given products are still associated with one or more subscriptions
 */
public void removeProductsByUuids(Owner owner,Collection<String> productUuids){
  if (owner == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (productUuids != null && !productUuids.isEmpty()) {
    this.ownerProductCurator.removeOwnerProductReferences(owner,productUuids);
  }
}
Program: 49248
Project: 49248
Buggy source:
@SuppressWarnings("String_Node_Str") public CandlepinQuery<Product> getProductsByContentUuids(Owner owner,Collection<String> contentUuids){
  if (contentUuids != null && !contentUuids.isEmpty()) {
    Criteria idCriteria=this.createSecureCriteria().createAlias("String_Node_Str","String_Node_Str").createAlias("String_Node_Str","String_Node_Str").add(CPRestrictions.in("String_Node_Str",contentUuids)).setProjection(Projections.distinct(Projections.id()));
    List<String> productUuids=idCriteria.list();
    if (productUuids != null && !productUuids.isEmpty()) {
      DetachedCriteria criteria=this.createSecureDetachedCriteria().add(CPRestrictions.in("String_Node_Str",productUuids));
      return this.cpQueryFactory.<Product>buildQuery(this.currentSession(),criteria);
    }
  }
  return this.cpQueryFactory.<Product>buildQuery();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public CandlepinQuery<Product> getProductsByContentUuids(Owner owner,Collection<String> contentUuids){
  if (contentUuids != null && !contentUuids.isEmpty()) {
    Criteria idCriteria=this.createSecureCriteria(OwnerProduct.class,null).createAlias("String_Node_Str","String_Node_Str").createAlias("String_Node_Str","String_Node_Str").createAlias("String_Node_Str","String_Node_Str").createAlias("String_Node_Str","String_Node_Str").add(Restrictions.eq("String_Node_Str",owner.getId())).add(CPRestrictions.in("String_Node_Str",contentUuids)).setProjection(Projections.distinct(Projections.property("String_Node_Str")));
    List<String> productUuids=idCriteria.list();
    if (productUuids != null && !productUuids.isEmpty()) {
      DetachedCriteria criteria=this.createSecureDetachedCriteria().add(CPRestrictions.in("String_Node_Str",productUuids));
      return this.cpQueryFactory.<Product>buildQuery(this.currentSession(),criteria);
    }
  }
  return this.cpQueryFactory.<Product>buildQuery();
}
Program: 49249
Project: 49249
Buggy source:
@Test @Parameters({"String_Node_Str","String_Node_Str"}) public void testRemoveContentDivergeFromExisting(boolean regenCerts){
  Owner owner1=this.createOwner("String_Node_Str","String_Node_Str");
  Owner owner2=this.createOwner("String_Node_Str","String_Node_Str");
  Product product=this.createProduct("String_Node_Str","String_Node_Str",owner1,owner2);
  Content content=this.createContent("String_Node_Str","String_Node_Str",owner1,owner2);
  product.addContent(content,true);
  product=this.productCurator.merge(product);
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner1));
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner2));
  this.contentManager.removeContent(owner1,content,regenCerts);
  assertFalse(this.ownerContentCurator.isContentMappedToOwner(content,owner1));
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner2));
  assertNotNull(this.contentCurator.find(content.getUuid()));
  if (regenCerts) {
    verify(this.mockEntCertGenerator,times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)),anyCollectionOf(Product.class),anyBoolean());
  }
 else {
    verifyZeroInteractions(this.mockEntCertGenerator);
  }
}

Fixed version (ground truth):
@Test @Parameters({"String_Node_Str","String_Node_Str"}) public void testRemoveContentDivergeFromExisting(boolean regenCerts){
  Owner owner1=this.createOwner("String_Node_Str","String_Node_Str");
  Owner owner2=this.createOwner("String_Node_Str","String_Node_Str");
  Product product=this.createProduct("String_Node_Str","String_Node_Str",owner1,owner2);
  Content content=this.createContent("String_Node_Str","String_Node_Str",owner1,owner2);
  product.addContent(content,true);
  product=this.productCurator.merge(product);
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner1));
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner2));
  try {
    this.beginTransaction();
    this.contentManager.removeContent(owner1,content,regenCerts);
    this.commitTransaction();
  }
 catch (  RuntimeException e) {
    this.rollbackTransaction();
  }
  assertFalse(this.ownerContentCurator.isContentMappedToOwner(content,owner1));
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner2));
  assertNotNull(this.contentCurator.find(content.getUuid()));
  if (regenCerts) {
    verify(this.mockEntCertGenerator,times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)),anyCollectionOf(Product.class),anyBoolean());
  }
 else {
    verifyZeroInteractions(this.mockEntCertGenerator);
  }
}
Program: 49250
Project: 49250
Buggy source:
@Test @Parameters({"String_Node_Str","String_Node_Str"}) public void testRemoveContent(boolean regenCerts){
  Owner owner=this.createOwner("String_Node_Str","String_Node_Str");
  Product product=this.createProduct("String_Node_Str","String_Node_Str",owner);
  Content content=this.createContent("String_Node_Str","String_Node_Str",owner);
  product.addContent(content,true);
  product=this.productCurator.merge(product);
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner));
  this.contentManager.removeContent(owner,content,regenCerts);
  assertFalse(this.ownerContentCurator.isContentMappedToOwner(content,owner));
  assertNotNull(this.contentCurator.find(content.getUuid()));
  assertEquals(0,this.ownerContentCurator.getOwnerCount(content));
  if (regenCerts) {
    verify(this.mockEntCertGenerator,times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner)),anyCollectionOf(Product.class),anyBoolean());
  }
 else {
    verifyZeroInteractions(this.mockEntCertGenerator);
  }
}

Fixed version (ground truth):
@Test @Parameters({"String_Node_Str","String_Node_Str"}) public void testRemoveContent(boolean regenCerts){
  Owner owner=this.createOwner("String_Node_Str","String_Node_Str");
  Product product=this.createProduct("String_Node_Str","String_Node_Str",owner);
  Content content=this.createContent("String_Node_Str","String_Node_Str",owner);
  product.addContent(content,true);
  product=this.productCurator.merge(product);
  assertTrue(this.ownerContentCurator.isContentMappedToOwner(content,owner));
  try {
    this.beginTransaction();
    this.contentManager.removeContent(owner,content,regenCerts);
    this.commitTransaction();
  }
 catch (  RuntimeException e) {
    this.rollbackTransaction();
  }
  assertFalse(this.ownerContentCurator.isContentMappedToOwner(content,owner));
  assertNotNull(this.contentCurator.find(content.getUuid()));
  assertEquals(0,this.ownerContentCurator.getOwnerCount(content));
  if (regenCerts) {
    verify(this.mockEntCertGenerator,times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner)),anyCollectionOf(Product.class),anyBoolean());
  }
 else {
    verifyZeroInteractions(this.mockEntCertGenerator);
  }
}
Program: 49255
Project: 49255
Buggy source:
/** 
 * Find an owner by ownerKey and lock it.
 * @param ownerKey the target Owner's key
 * @return the Owner with the specified key, or null if not found.
 */
@Transactional public Owner findAndLock(String ownerKey){
  List<Owner> result=getEntityManager().createQuery("String_Node_Str",Owner.class).setParameter("String_Node_Str",ownerKey).setMaxResults(1).setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
  if (result == null || result.isEmpty()) {
    return null;
  }
  return result.get(0);
}

Fixed version (ground truth):
/** 
 * Find an owner by ownerKey and lock it.
 * @param ownerKey the target Owner's key
 * @return the Owner with the specified key, or null if not found.
 */
@Transactional public Owner findAndLock(String ownerKey){
  List<Owner> result=getEntityManager().createQuery("String_Node_Str",Owner.class).setParameter("String_Node_Str",ownerKey).setMaxResults(1).setLockMode(LockModeType.PESSIMISTIC_WRITE).getResultList();
  if (result == null || result.isEmpty()) {
    return null;
  }
  Owner owner=result.get(0);
  getEntityManager().refresh(owner,LockModeType.PESSIMISTIC_WRITE);
  return owner;
}
Program: 49256
Project: 49256
Buggy source:
@Inject public ContentManager(ContentCurator contentCurator,OwnerContentCurator ownerContentCurator,ProductCurator productCurator,ProductManager productManager,EntitlementCertificateGenerator entitlementCertGenerator,Configuration config){
  this.contentCurator=contentCurator;
  this.ownerContentCurator=ownerContentCurator;
  this.productCurator=productCurator;
  this.productManager=productManager;
  this.entitlementCertGenerator=entitlementCertGenerator;
}

Fixed version (ground truth):
@Inject public ContentManager(ContentCurator contentCurator,EntitlementCertificateGenerator entitlementCertGenerator,OwnerContentCurator ownerContentCurator,ProductCurator productCurator,ProductManager productManager){
  this.contentCurator=contentCurator;
  this.entitlementCertGenerator=entitlementCertGenerator;
  this.ownerContentCurator=ownerContentCurator;
  this.productCurator=productCurator;
  this.productManager=productManager;
}
Program: 49260
Project: 49260
Buggy source:
@Inject public ProductManager(ContentCurator contentCurator,EntitlementCertificateGenerator entitlementCertGenerator,ProductCurator productCurator,OwnerProductCurator ownerProductCurator,Configuration config){
  this.contentCurator=contentCurator;
  this.entitlementCertGenerator=entitlementCertGenerator;
  this.ownerProductCurator=ownerProductCurator;
  this.productCurator=productCurator;
}

Fixed version (ground truth):
@Inject public ProductManager(ContentCurator contentCurator,EntitlementCertificateGenerator entitlementCertGenerator,OwnerProductCurator ownerProductCurator,ProductCurator productCurator){
  this.contentCurator=contentCurator;
  this.entitlementCertGenerator=entitlementCertGenerator;
  this.ownerProductCurator=ownerProductCurator;
  this.productCurator=productCurator;
}
Program: 49261
Project: 49261
Buggy source:
/** 
 * Copies several properties from the given content on to this content instance. Properties that are not copied over include any identifiying fields (UUID, ID), the creation date and locking states. Values on the source content which are null will be ignored.
 * @param source The source content instance from which to pull content information
 * @return this content instance
 */
public Content merge(Content source){
  this.setUpdated(source.getUpdated() != null ? (Date)source.getUpdated().clone() : null);
  this.setType(source.getType());
  this.setLabel(source.getLabel());
  this.setName(source.getName());
  this.setVendor(source.getVendor());
  this.setContentUrl(source.getContentUrl());
  this.setRequiredTags(source.getRequiredTags());
  this.setReleaseVer(source.getReleaseVer());
  this.setGpgUrl(source.getGpgUrl());
  this.setMetadataExpire(source.getMetadataExpire());
  this.setArches(source.getArches());
  this.setModifiedProductIds(source.getModifiedProductIds());
  return this;
}

Fixed version (ground truth):
/** 
 * Copies several properties from the given content on to this content instance. Properties that are not copied over include any identifiying fields (UUID, ID), the creation date and locking states. Values on the source content which are null will be ignored.
 * @param source The source content instance from which to pull content information
 * @return this content instance
 */
public Content merge(Content source){
  this.setUpdated(source.getUpdated() != null ? (Date)source.getUpdated().clone() : null);
  this.setType(source.getType());
  this.setLabel(source.getLabel());
  this.setName(source.getName());
  this.setVendor(source.getVendor());
  this.setContentUrl(source.getContentUrl());
  this.setRequiredTags(source.getRequiredTags());
  this.setReleaseVersion(source.getReleaseVersion());
  this.setGpgUrl(source.getGpgUrl());
  this.setMetadataExpire(source.getMetadataExpire());
  this.setArches(source.getArches());
  this.setModifiedProductIds(source.getModifiedProductIds());
  return this;
}
Program: 49262
Project: 49262
Buggy source:
/** 
 * Populates this DTO with data from the given source entity.
 * @param source The source entity from which to copy data
 * @throws IllegalArgumentException if source is null
 * @return a reference to this DTO
 */
public ContentData populate(Content source){
  if (source == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  super.populate(source);
  this.uuid=source.getUuid();
  this.id=source.getId();
  this.type=source.getType();
  this.label=source.getLabel();
  this.name=source.getName();
  this.vendor=source.getVendor();
  this.contentUrl=source.getContentUrl();
  this.requiredTags=source.getRequiredTags();
  this.releaseVer=source.getReleaseVer();
  this.gpgUrl=source.getGpgUrl();
  this.metadataExpire=source.getMetadataExpire();
  this.setModifiedProductIds(source.getModifiedProductIds());
  return this;
}

Fixed version (ground truth):
/** 
 * Populates this DTO with data from the given source entity.
 * @param source The source entity from which to copy data
 * @throws IllegalArgumentException if source is null
 * @return a reference to this DTO
 */
public ContentData populate(Content source){
  if (source == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  super.populate(source);
  this.uuid=source.getUuid();
  this.id=source.getId();
  this.type=source.getType();
  this.label=source.getLabel();
  this.name=source.getName();
  this.vendor=source.getVendor();
  this.contentUrl=source.getContentUrl();
  this.requiredTags=source.getRequiredTags();
  this.releaseVer=source.getReleaseVersion();
  this.gpgUrl=source.getGpgUrl();
  this.metadataExpire=source.getMetadataExpire();
  this.setModifiedProductIds(source.getModifiedProductIds());
  return this;
}
Program: 49263
Project: 49263
Buggy source:
/** 
 * Adds the given content to this product DTO. If a matching content has already been added to this product, it will be overwritten by the specified content.
 * @param content The product content DTO to add to this product
 * @throws IllegalArgumentException if content is null
 * @return true if adding the content resulted in a change to this product; false otherwise
 */
public boolean addProductContent(ProductContent content){
  if (content == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return this.addProductContent(new ProductContentData(content));
}

Fixed version (ground truth):
/** 
 * Adds the given content to this product DTO. If a matching content has already been added to this product, it will be overwritten by the specified content.
 * @param productContent The product content DTO to add to this product
 * @throws IllegalArgumentException if productContent is null
 * @return true if adding the content resulted in a change to this product; false otherwise
 */
public boolean addProductContent(ProductContent productContent){
  if (productContent == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return this.addProductContent(productContent.toDTO());
}
Program: 49264
Project: 49264
Buggy source:
/** 
 * Adds the given content to this product DTO. If a matching content has already been added to this product, it will be overwritten by the specified content.
 * @param content The product content DTO to add to this product
 * @throws IllegalArgumentException if content is null
 * @return true if adding the content resulted in a change to this product; false otherwise
 */
public boolean addContent(Content content,boolean enabled){
  if (content == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return this.addProductContent(new ProductContentData(new ContentData(content),enabled));
}

Fixed version (ground truth):
/** 
 * Adds the given content to this product DTO. If a matching content has already been added to this product, it will be overwritten by the specified content.
 * @param content The product content DTO to add to this product
 * @throws IllegalArgumentException if content is null
 * @return true if adding the content resulted in a change to this product; false otherwise
 */
public boolean addContent(Content content,boolean enabled){
  if (content == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return this.addProductContent(new ProductContentData(content.toDTO(),enabled));
}
Program: 49265
Project: 49265
Buggy source:
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @ApiResponses({@ApiResponse(code=400,message="String_Node_Str")}) @GET @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public Content getContent(@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey,@PathParam("String_Node_Str") String contentId){
  Owner owner=this.getOwnerByKey(ownerKey);
  Content content=this.contentCurator.lookupById(owner,contentId);
  if (content == null) {
    throw new NotFoundException(i18n.tr("String_Node_Str",contentId));
  }
  return content;
}

Fixed version (ground truth):
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @ApiResponses({@ApiResponse(code=400,message="String_Node_Str")}) @GET @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public ContentData getContent(@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey,@PathParam("String_Node_Str") String contentId){
  Owner owner=this.getOwnerByKey(ownerKey);
  Content content=this.fetchContent(owner,contentId);
  return content.toDTO();
}
Program: 49266
Project: 49266
Buggy source:
/** 
 * Creates or merges the given Content object.
 * @param owner The owner for which to create the new content
 * @param content The content to create or merge
 * @return the newly created and/or merged Content object.
 */
private Content createContentImpl(Owner owner,ContentData content){
  Content entity=null;
  if (content.getId() == null || content.getId().trim().length() == 0) {
    content.setId(this.idGenerator.generateId());
    entity=this.contentManager.createContent(content,owner);
  }
 else {
    Content existing=this.ownerContentCurator.getContentById(owner,content.getId());
    if (existing != null) {
      entity=this.contentManager.updateContent(existing,content,owner,true);
    }
 else {
      entity=this.contentManager.createContent(content,owner);
    }
  }
  return entity;
}

Fixed version (ground truth):
/** 
 * Creates or merges the given Content object.
 * @param owner The owner for which to create the new content
 * @param content The content to create or merge
 * @return the newly created and/or merged Content object.
 */
private Content createContentImpl(Owner owner,ContentData content){
  Content entity=null;
  if (content.getId() == null || content.getId().trim().length() == 0) {
    content.setId(this.idGenerator.generateId());
    entity=this.contentManager.createContent(content,owner);
  }
 else {
    Content existing=this.ownerContentCurator.getContentById(owner,content.getId());
    if (existing != null) {
      if (existing.isLocked()) {
        throw new ForbiddenException(i18n.tr("String_Node_Str",existing.getId()));
      }
      entity=this.contentManager.updateContent(existing,content,owner,true);
    }
 else {
      entity=this.contentManager.createContent(content,owner);
    }
  }
  return entity;
}
Program: 49267
Project: 49267
Buggy source:
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @GET @Produces(MediaType.APPLICATION_JSON) public List<Content> list(@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey){
  Owner owner=this.getOwnerByKey(ownerKey);
  return contentCurator.listByOwner(owner);
}

Fixed version (ground truth):
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @GET @Produces(MediaType.APPLICATION_JSON) public Response list(@Verify(Owner.class) @PathParam("String_Node_Str") String ownerKey){
  final Owner owner=this.getOwnerByKey(ownerKey);
  final Collection<Content> contents=this.ownerContentCurator.getContentByOwner(owner);
  final ObjectMapper mapper=new JsonProvider(true).locateMapper(Object.class,MediaType.APPLICATION_JSON_TYPE);
  StreamingOutput output=new StreamingOutput(){
    @Override public void write(    OutputStream stream) throws IOException, WebApplicationException {
      JsonGenerator generator=mapper.getJsonFactory().createGenerator(stream);
      generator.writeStartArray();
      for (      Content content : contents) {
        mapper.writeValue(generator,content.toDTO());
      }
      generator.writeEndArray();
      generator.flush();
    }
  }
;
  return Response.ok(output).build();
}
Program: 49268
Project: 49268
Buggy source:
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public ContentData updateContent(@PathParam("String_Node_Str") String ownerKey,@PathParam("String_Node_Str") String contentId,ContentData content){
  Owner owner=this.getOwnerByKey(ownerKey);
  Content existing=this.getContent(ownerKey,contentId);
  if (existing.isLocked()) {
    throw new ForbiddenException(i18n.tr("String_Node_Str",content.getId()));
  }
  existing=this.contentManager.updateContent(existing,content,owner,true);
  return existing.toDTO();
}

Fixed version (ground truth):
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public ContentData updateContent(@PathParam("String_Node_Str") String ownerKey,@PathParam("String_Node_Str") String contentId,ContentData content){
  Owner owner=this.getOwnerByKey(ownerKey);
  Content existing=this.fetchContent(owner,contentId);
  if (existing.isLocked()) {
    throw new ForbiddenException(i18n.tr("String_Node_Str",existing.getId()));
  }
  existing=this.contentManager.updateContent(existing,content,owner,true);
  return existing.toDTO();
}
Program: 49269
Project: 49269
Buggy source:
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public void remove(@PathParam("String_Node_Str") String ownerKey,@PathParam("String_Node_Str") String contentId){
  Owner owner=this.getOwnerByKey(ownerKey);
  Content content=this.getContent(ownerKey,contentId);
  if (content.isLocked()) {
    throw new ForbiddenException(i18n.tr("String_Node_Str",content.getId()));
  }
  this.contentManager.removeContent(content,owner,true);
}

Fixed version (ground truth):
@ApiOperation(notes="String_Node_Str",value="String_Node_Str") @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public void remove(@PathParam("String_Node_Str") String ownerKey,@PathParam("String_Node_Str") String contentId){
  Owner owner=this.getOwnerByKey(ownerKey);
  Content content=this.fetchContent(owner,contentId);
  if (content.isLocked()) {
    throw new ForbiddenException(i18n.tr("String_Node_Str",content.getId()));
  }
  this.contentManager.removeContent(content,owner,true);
}
Program: 49270
Project: 49270
Buggy source:
public Set<Content> getChangedContent(Owner owner,Map<String,ContentData> contentCache){
  Set<Content> changed=Util.newSet();
  log.debug("String_Node_Str",contentCache.size());
  for (  String cid : contentCache.keySet()) {
    ContentData incoming=contentCache.get(cid);
    Content existing=this.contentCurator.lookupById(owner,cid);
    incoming.setLocked(true);
    if (existing == null) {
      log.info("String_Node_Str",owner.getKey(),cid);
      existing=this.contentManager.createContent(incoming,owner);
    }
 else     if (!existing.isChangedBy(incoming)) {
      log.info("String_Node_Str",owner.getKey(),cid);
      existing=this.contentManager.updateContent(existing,incoming,owner,false);
      changed.add(existing);
    }
  }
  return changed;
}

Fixed version (ground truth):
public Set<Content> getChangedContent(Owner owner,Map<String,ContentData> contentCache){
  Set<Content> changed=Util.newSet();
  log.debug("String_Node_Str",contentCache.size());
  for (  String cid : contentCache.keySet()) {
    ContentData incoming=contentCache.get(cid);
    Content existing=this.ownerContentCurator.getContentById(owner,cid);
    if (existing == null) {
      log.info("String_Node_Str",owner.getKey(),cid);
      existing=this.contentManager.createContent(incoming,owner);
    }
 else     if (existing.isChangedBy(incoming)) {
      log.info("String_Node_Str",owner.getKey(),cid);
      existing=this.contentManager.updateContent(existing,incoming,owner,false);
      changed.add(existing);
    }
 else {
      log.info("String_Node_Str");
    }
  }
  return changed;
}
Program: 49272
Project: 49272
Buggy source:
public Set<Product> getChangedProducts(Owner owner,Map<String,ProductData> productCache){
  log.debug("String_Node_Str",productCache.size());
  Set<Product> changedProducts=Util.newSet();
  for (  String pid : productCache.keySet()) {
    ProductData incoming=productCache.get(pid);
    Product existing=this.ownerProductCurator.getProductById(owner,pid);
    incoming.setLocked(true);
    if (existing == null) {
      log.info("String_Node_Str",owner.getKey(),pid);
      existing=this.productManager.createProduct(incoming,owner);
    }
 else     if (!existing.isChangedBy(incoming)) {
      log.info("String_Node_Str",owner.getKey(),pid);
      existing=this.productManager.updateProduct(existing,incoming,owner,false);
      changedProducts.add(existing);
    }
  }
  return changedProducts;
}

Fixed version (ground truth):
public Set<Product> getChangedProducts(Owner owner,Map<String,ProductData> productCache){
  log.debug("String_Node_Str",productCache.size());
  Set<Product> changedProducts=Util.newSet();
  for (  String pid : productCache.keySet()) {
    ProductData incoming=productCache.get(pid);
    Product existing=this.ownerProductCurator.getProductById(owner,pid);
    incoming.setLocked(true);
    if (existing == null) {
      log.info("String_Node_Str",owner.getKey(),pid);
      existing=this.productManager.createProduct(incoming,owner);
    }
 else     if (existing.isChangedBy(incoming)) {
      log.info("String_Node_Str",owner.getKey(),pid);
      existing=this.productManager.updateProduct(existing,incoming,owner,false);
      changedProducts.add(existing);
    }
  }
  return changedProducts;
}
Program: 49273
Project: 49273
Buggy source:
private void updateContentRefs(Map<String,Content> contentCache,Owner owner,Product product){
  if (product == null) {
    return;
  }
  for (  ProductContent pc : product.getProductContent()) {
    Content content=pc.getContent();
    Content existing=this.contentCurator.lookupById(owner,content.getId());
    if (existing == null) {
      throw new RuntimeException(String.format("String_Node_Str",content));
    }
    pc.setContent(existing);
  }
}

Fixed version (ground truth):
private void updateContentRefs(Map<String,Content> contentCache,Owner owner,Product product){
  if (product == null) {
    return;
  }
  for (  ProductContent pc : product.getProductContent()) {
    Content content=pc.getContent();
    Content existing=this.ownerContentCurator.getContentById(owner,content.getId());
    if (existing == null) {
      throw new RuntimeException(String.format("String_Node_Str",content));
    }
    pc.setContent(existing);
  }
}
Program: 49274
Project: 49274
Buggy source:
/** 
 * Refreshes the specified content under the given owner/org.
 * @param owner The owner for which to refresh content
 * @param subs The subscriptions from which to pull content
 * @return the set of existing content which was updated/changed as a result of this operation
 */
protected Set<Content> refreshContent(Owner owner,Collection<Subscription> subs){
  Map<String,ContentData> content=new HashMap<String,ContentData>();
  log.info("String_Node_Str",subs.size());
  for (  Subscription sub : subs) {
    this.addProductContentToMap(content,sub.getProduct());
    this.addProductContentToMap(content,sub.getDerivedProduct());
    for (    ProductData product : sub.getProvidedProducts()) {
      this.addProductContentToMap(content,product);
    }
    for (    ProductData product : sub.getDerivedProvidedProducts()) {
      this.addProductContentToMap(content,product);
    }
  }
  Set<Content> changed=this.getChangedContent(owner,content);
  this.contentCurator.flush();
  return changed;
}

Fixed version (ground truth):
/** 
 * Refreshes the specified content under the given owner/org.
 * @param owner The owner for which to refresh content
 * @param subs The subscriptions from which to pull content
 * @return the set of existing content which was updated/changed as a result of this operation
 */
protected Set<Content> refreshContent(Owner owner,Collection<Subscription> subs){
  Map<String,ContentData> content=new HashMap<String,ContentData>();
  log.info("String_Node_Str",subs.size());
  if (subs != null) {
    for (    Subscription sub : subs) {
      this.addProductContentToMap(content,sub.getProduct());
      this.addProductContentToMap(content,sub.getDerivedProduct());
      for (      ProductData product : sub.getProvidedProducts()) {
        this.addProductContentToMap(content,product);
      }
      for (      ProductData product : sub.getDerivedProvidedProducts()) {
        this.addProductContentToMap(content,product);
      }
    }
  }
  Set<Content> changed=this.getChangedContent(owner,content);
  this.ownerContentCurator.flush();
  return changed;
}