nus-yam/ex-repair huggingface dataset:
Program: 49561
Project: 49561
Buggy source:
@Test public void testRefreshPoolsWithChangedSubscriptions(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Pool pool=createPoolAndSub(createOwner(),prod,new Long(1000),TestUtil.createDate(2009,11,30),TestUtil.createDate(2015,11,30));
  Owner owner=pool.getOwner();
  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);
  assertTrue(pool.getQuantity() < sub.getQuantity());
  assertTrue(pool.getStartDate() != sub.getStartDate());
  assertTrue(pool.getEndDate() != sub.getEndDate());
  pool.setSubscriptionId(sub.getId());
  poolCurator.merge(pool);
  ownerResource.refreshEntitlementPools(owner.getKey());
  pool=poolCurator.find(pool.getId());
  assertEquals(sub.getId(),pool.getSubscriptionId());
  assertEquals(sub.getQuantity(),pool.getQuantity());
  assertEquals(sub.getStartDate(),pool.getStartDate());
  assertEquals(sub.getEndDate(),pool.getEndDate());
}

Fixed version (ground truth):
@Test public void testRefreshPoolsWithChangedSubscriptions(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Pool pool=createPoolAndSub(createOwner(),prod,new Long(1000),TestUtil.createDate(2009,11,30),TestUtil.createDate(2015,11,30));
  Owner owner=pool.getOwner();
  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);
  assertTrue(pool.getQuantity() < sub.getQuantity());
  assertTrue(pool.getStartDate() != sub.getStartDate());
  assertTrue(pool.getEndDate() != sub.getEndDate());
  pool.setSubscriptionId(sub.getId());
  poolCurator.merge(pool);
  ownerResource.refreshEntitlementPools(owner.getKey(),false);
  pool=poolCurator.find(pool.getId());
  assertEquals(sub.getId(),pool.getSubscriptionId());
  assertEquals(sub.getQuantity(),pool.getQuantity());
  assertEquals(sub.getStartDate(),pool.getStartDate());
  assertEquals(sub.getEndDate(),pool.getEndDate());
}
Program: 49562
Project: 49562
Buggy source:
@Test public void testRefreshPoolsWithNewSubscriptions(){
  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);
  assertEquals(sub.getId(),newPool.getSubscriptionId());
  assertEquals(sub.getQuantity(),newPool.getQuantity());
  assertEquals(sub.getStartDate(),newPool.getStartDate());
  assertEquals(sub.getEndDate(),newPool.getEndDate());
}

Fixed version (ground truth):
@Test public void testRefreshPoolsWithNewSubscriptions(){
  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);
  assertEquals(sub.getId(),newPool.getSubscriptionId());
  assertEquals(sub.getQuantity(),newPool.getQuantity());
  assertEquals(sub.getStartDate(),newPool.getStartDate());
  assertEquals(sub.getEndDate(),newPool.getEndDate());
}
Program: 49563
Project: 49563
Buggy source:
/** 
 * @return
 */
private void doTestEntitlementsRevocationCommon(long subQ,int e1,int e2,boolean fifo){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Pool pool=createPoolAndSub(createOwner(),prod,new Long(1000),TestUtil.createDate(2009,11,30),TestUtil.createDate(2015,11,30));
  Owner owner=pool.getOwner();
  Consumer consumer=createConsumer(owner);
  Consumer consumer1=createConsumer(owner);
  Subscription sub=this.subCurator.find(pool.getSubscriptionId());
  sub.setQuantity(subQ);
  this.subCurator.merge(sub);
  this.ownerResource.refreshEntitlementPools(owner.getKey());
  pool=this.poolCurator.find(pool.getId());
  createEntitlementWithQ(pool,owner,consumer,e1,"String_Node_Str");
  createEntitlementWithQ(pool,owner,consumer1,e2,"String_Node_Str");
  assertEquals(pool.getConsumed(),Long.valueOf(e1 + e2));
  this.config.setProperty(ConfigProperties.REVOKE_ENTITLEMENT_IN_FIFO_ORDER,fifo ? "String_Node_Str" : "String_Node_Str");
  this.ownerResource.refreshEntitlementPools(owner.getKey());
  pool=poolCurator.find(pool.getId());
}

Fixed version (ground truth):
/** 
 * @return
 */
private void doTestEntitlementsRevocationCommon(long subQ,int e1,int e2,boolean fifo){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Pool pool=createPoolAndSub(createOwner(),prod,new Long(1000),TestUtil.createDate(2009,11,30),TestUtil.createDate(2015,11,30));
  Owner owner=pool.getOwner();
  Consumer consumer=createConsumer(owner);
  Consumer consumer1=createConsumer(owner);
  Subscription sub=this.subCurator.find(pool.getSubscriptionId());
  sub.setQuantity(subQ);
  this.subCurator.merge(sub);
  this.ownerResource.refreshEntitlementPools(owner.getKey(),false);
  pool=this.poolCurator.find(pool.getId());
  createEntitlementWithQ(pool,owner,consumer,e1,"String_Node_Str");
  createEntitlementWithQ(pool,owner,consumer1,e2,"String_Node_Str");
  assertEquals(pool.getConsumed(),Long.valueOf(e1 + e2));
  this.config.setProperty(ConfigProperties.REVOKE_ENTITLEMENT_IN_FIFO_ORDER,fifo ? "String_Node_Str" : "String_Node_Str");
  this.ownerResource.refreshEntitlementPools(owner.getKey(),false);
  pool=poolCurator.find(pool.getId());
}
Program: 49565
Project: 49565
Buggy source:
public CertificateSerial(Long id){
  this.id=id;
}

Fixed version (ground truth):
/** 
 */
public CertificateSerial(){
  super();
}
Program: 49566
Project: 49566
Buggy source:
@Inject public CertificateRevocationListTask(PKIReader rdr,Config conf){
  this.pkiReader=rdr;
  this.config=conf;
}

Fixed version (ground truth):
/** 
 * Instantiates a new certificate revocation list task.
 * @param rdr the rdr
 * @param conf the conf
 * @param curator the curator
 * @param algorithm the algorithm
 */
@Inject public CertificateRevocationListTask(PKIReader rdr,Config conf,CertificateSerialCurator curator,@Named("String_Node_Str") String algorithm){
  this.pkiReader=rdr;
  this.config=conf;
  this.certificateSerialCurator=curator;
  this.algorithm=algorithm;
}
Program: 49567
Project: 49567
Buggy source:
protected List<SimpleCRLEntry> toSimpleCRLEntries(Set<? extends X509CRLEntry> entries){
  List<SimpleCRLEntry> crlEntries=newList();
  for (  X509CRLEntry entry : entries) {
    crlEntries.add(new SimpleCRLEntry(entry.getSerialNumber(),entry.getRevocationDate()));
  }
  return crlEntries;
}

Fixed version (ground truth):
/** 
 * To simple crl entries.
 * @param entries the entries
 * @return the list
 */
protected List<SimpleCRLEntry> toSimpleCRLEntries(Set<? extends X509CRLEntry> entries){
  List<SimpleCRLEntry> crlEntries=newList();
  for (  X509CRLEntry entry : entries) {
    crlEntries.add(new SimpleCRLEntry(entry.getSerialNumber(),entry.getRevocationDate()));
  }
  return crlEntries;
}
Program: 49568
Project: 49568
Buggy source:
protected X509CRL generateCRL(Iterator<SimpleCRLEntry> entries,String principal,BigInteger crlNumber){
  try {
    X509V2CRLGenerator generator=new X509V2CRLGenerator();
    generator.setIssuerDN(new X500Principal(principal));
    generator.setThisUpdate(new Date());
    while (entries.hasNext()) {
      SimpleCRLEntry entry=entries.next();
      generator.addCRLEntry(entry.serialNumber,entry.revocationDate,CRLReason.privilegeWithdrawn);
    }
    generator.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(pkiReader.getCACert()));
    generator.addExtension(X509Extensions.CRLNumber,false,new CRLNumber(crlNumber));
    return generator.generate(pkiReader.getCaKey());
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Generate crl.
 * @param entries the entries
 * @param principal the principal
 * @param crlNumber the crl number
 * @return the x509 crl
 */
protected X509CRL generateCRL(Iterator<SimpleCRLEntry> entries,String principal,BigInteger crlNumber){
  try {
    X509V2CRLGenerator generator=new X509V2CRLGenerator();
    generator.setIssuerDN(new X500Principal(principal));
    generator.setThisUpdate(new Date());
    generator.setNextUpdate(Util.tomorrow());
    generator.setSignatureAlgorithm(algorithm);
    while (entries.hasNext()) {
      SimpleCRLEntry entry=entries.next();
      generator.addCRLEntry(entry.serialNumber,entry.revocationDate,CRLReason.privilegeWithdrawn);
    }
    L.info("String_Node_Str");
    generator.addExtension(X509Extensions.AuthorityKeyIdentifier,false,new AuthorityKeyIdentifierStructure(pkiReader.getCACert()));
    generator.addExtension(X509Extensions.CRLNumber,false,new CRLNumber(crlNumber));
    return generator.generate(pkiReader.getCaKey());
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 49569
Project: 49569
Buggy source:
protected List<SimpleCRLEntry> getNewSerialsToAppendAndSetThemConsumed(){
  List<SimpleCRLEntry> entries=Util.newList();
  List<CertificateSerial> serials=this.certificateSerialCurator.retrieveTobeCollectedSerials();
  for (  CertificateSerial cs : serials) {
    entries.add(new SimpleCRLEntry(cs.getSerial(),cs.getExpiration()));
    cs.setCollected(true);
  }
  this.certificateSerialCurator.saveOrUpdateAll(serials);
  return entries;
}

Fixed version (ground truth):
/** 
 * Gets the new serials to append and set them consumed.
 * @return the new serials to append and set them consumed
 */
protected List<SimpleCRLEntry> getNewSerialsToAppendAndSetThemConsumed(){
  List<SimpleCRLEntry> entries=Util.newList();
  List<CertificateSerial> serials=this.certificateSerialCurator.retrieveTobeCollectedSerials();
  for (  CertificateSerial cs : serials) {
    entries.add(new SimpleCRLEntry(cs.getSerial(),cs.getExpiration()));
    cs.setCollected(true);
  }
  L.info("String_Node_Str" + serials.size() + "String_Node_Str");
  if (L.isDebugEnabled()) {
    StringBuilder builder=new StringBuilder("String_Node_Str");
    for (    CertificateSerial cs : serials) {
      builder.append(cs.getSerial()).append("String_Node_Str");
    }
    builder.append("String_Node_Str");
    L.debug("String_Node_Str" + builder.toString());
  }
  this.certificateSerialCurator.saveOrUpdateAll(serials);
  return entries;
}
Program: 49570
Project: 49570
Buggy source:
public void updateCRL(File file,String principal){
  FileInputStream in=null;
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  try {
    if (file.exists()) {
      in=new FileInputStream(file);
    }
    updateCRL(in,principal,stream);
    FileUtils.writeByteArrayToFile(file,stream.toByteArray());
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Update crl.
 * @param file the file
 * @param principal the principal
 */
public void updateCRL(File file,String principal){
  FileInputStream in=null;
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  try {
    if (file.exists() && file.length() > 0) {
      L.info("String_Node_Str" + file + "String_Node_Str");
      in=new FileInputStream(file);
    }
 else {
      L.info("String_Node_Str" + file + "String_Node_Str");
    }
    updateCRL(in,principal,stream);
    L.info("String_Node_Str");
    FileUtils.writeByteArrayToFile(file,stream.toByteArray());
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 49571
Project: 49571
Buggy source:
/** 
 * @param serialNumber
 * @param revocationDate
 */
private SimpleCRLEntry(BigInteger serialNumber,Date revocationDate){
  super();
  this.serialNumber=serialNumber;
  this.revocationDate=revocationDate;
}

Fixed version (ground truth):
/** 
 * Instantiates a new simple crl entry.
 * @param serialNumber the serial number
 * @param revocationDate the revocation date
 */
private SimpleCRLEntry(BigInteger serialNumber,Date revocationDate){
  this.serialNumber=serialNumber;
  this.revocationDate=revocationDate;
}
Program: 49572
Project: 49572
Buggy source:
/** 
 * @param x509crl
 * @return
 */
protected BigInteger getCRLNumber(X509CRL x509crl){
  if (x509crl == null) {
    return BigInteger.ONE;
  }
  return new BigInteger(getValue(x509crl,"String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Gets the cRL number.
 * @param x509crl the x509crl
 * @return the cRL number
 */
protected BigInteger getCRLNumber(X509CRL x509crl){
  if (x509crl == null) {
    return BigInteger.ZERO;
  }
  return new BigInteger(getValue(x509crl,"String_Node_Str"));
}
Program: 49573
Project: 49573
Buggy source:
@Override public void execute(JobExecutionContext ctx) throws JobExecutionException {
  File crlFile=new File(config.getString(ConfigProperties.CRL_FILE_PATH));
  this.updateCRL(crlFile,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void execute(JobExecutionContext ctx) throws JobExecutionException {
  String filePath=config.getString(ConfigProperties.CRL_FILE_PATH);
  L.info("String_Node_Str" + filePath);
  File crlFile=new File(filePath);
  Principal systemPrincipal=new SystemPrincipal();
  ResteasyProviderFactory.pushContext(Principal.class,systemPrincipal);
  this.updateCRL(crlFile,"String_Node_Str" + UUID.randomUUID());
  ResteasyProviderFactory.popContextData(Principal.class);
}
Program: 49574
Project: 49574
Buggy source:
protected Set<? extends X509CRLEntry> removeExpiredSerials(Set<? extends X509CRLEntry> revokedEntries){
  if (revokedEntries == null || revokedEntries.size() == 0) {
    return revokedEntries;
  }
  Map<BigInteger,X509CRLEntry> map=newMap();
  for (  X509CRLEntry entry : revokedEntries) {
    map.put(entry.getSerialNumber(),entry);
  }
  for (  CertificateSerial cs : this.certificateSerialCurator.getExpiredSerials()) {
    X509CRLEntry entry=map.get(cs.getSerial());
    if (entry != null) {
      revokedEntries.remove(entry);
    }
  }
  return revokedEntries;
}

Fixed version (ground truth):
/** 
 * Removes the expired serials.
 * @param revokedEntries the revoked entries
 * @return the set
 */
protected Set<? extends X509CRLEntry> removeExpiredSerials(Set<? extends X509CRLEntry> revokedEntries){
  if (revokedEntries == null || revokedEntries.size() == 0) {
    return Util.newSet();
  }
  Map<BigInteger,X509CRLEntry> map=newMap();
  for (  X509CRLEntry entry : revokedEntries) {
    map.put(entry.getSerialNumber(),entry);
  }
  for (  CertificateSerial cs : this.certificateSerialCurator.getExpiredSerials()) {
    X509CRLEntry entry=map.get(cs.getSerial());
    if (entry != null) {
      revokedEntries.remove(entry);
      L.info("String_Node_Str" + cs.getId() + "String_Node_Str");
    }
  }
  return revokedEntries;
}
Program: 49576
Project: 49576
Buggy source:
private void exportProducts(File baseDir,Consumer consumer) throws IOException {
  File productDir=new File(baseDir.getCanonicalPath(),"String_Node_Str");
  productDir.mkdir();
  Map<String,Product> products=new HashMap<String,Product>();
  for (  Entitlement entitlement : consumer.getEntitlements()) {
    for (    String productId : entitlement.getPool().getProvidedProductIds()) {
      if (!products.containsKey(productId)) {
        products.put(productId,productAdapter.getProductById(productId));
      }
    }
  }
  for (  Product product : products.values()) {
    File file=new File(productDir.getCanonicalPath(),product.getId() + "String_Node_Str");
    FileWriter writer=new FileWriter(file);
    productExporter.export(mapper,writer,product);
    writer.close();
    if (!product.getAttribute("String_Node_Str").equals("String_Node_Str")) {
      file=new File(productDir.getCanonicalPath(),product.getId() + "String_Node_Str");
      writer=new FileWriter(file);
      productCertExporter.export(writer,productAdapter.getProductCertificate(product));
      writer.close();
    }
  }
}

Fixed version (ground truth):
private void exportProducts(File baseDir,Consumer consumer) throws IOException {
  File productDir=new File(baseDir.getCanonicalPath(),"String_Node_Str");
  productDir.mkdir();
  Map<String,Product> products=new HashMap<String,Product>();
  for (  Entitlement entitlement : consumer.getEntitlements()) {
    for (    String productId : entitlement.getPool().getProvidedProductIds()) {
      if (!products.containsKey(productId)) {
        products.put(productId,productAdapter.getProductById(productId));
      }
    }
  }
  for (  Product product : products.values()) {
    File file=new File(productDir.getCanonicalPath(),product.getId() + "String_Node_Str");
    FileWriter writer=new FileWriter(file);
    productExporter.export(mapper,writer,product);
    writer.close();
    if (!product.getAttributeValue("String_Node_Str").equals("String_Node_Str")) {
      file=new File(productDir.getCanonicalPath(),product.getId() + "String_Node_Str");
      writer=new FileWriter(file);
      productCertExporter.export(writer,productAdapter.getProductCertificate(product));
      writer.close();
    }
  }
}
Program: 49577
Project: 49577
Buggy source:
private Entitlement addEntitlement(Consumer consumer,Pool pool,Integer quantity) throws EntitlementRefusedException {
  PreEntHelper preHelper=enforcer.pre(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(),quantity);
  consumer.addEntitlement(e);
  if (preHelper.getGrantFreeEntitlement()) {
    log.info("String_Node_Str");
    e.setIsFree(Boolean.TRUE);
  }
 else {
    pool.bumpConsumed();
  }
  postEntHelper.init(e);
  enforcer.post(postEntHelper,e);
  entitlementCurator.create(e);
  consumerCurator.update(consumer);
  Pool mergedPool=epCurator.merge(pool);
  Subscription sub=subAdapter.getSubscription(mergedPool.getSubscriptionId());
  if (sub == null) {
    log.warn("String_Node_Str" + pool.getId());
  }
 else {
    try {
      EntitlementCertificate cert=this.entCertAdapter.generateEntitlementCert(consumer,e,sub,sub.getProduct(),sub.getEndDate(),new BigInteger(serialCurator.getNextSerial().toString()));
      e.getCertificates().add(cert);
      this.entCertCurator.create(cert);
    }
 catch (    Exception ex) {
      throw new RuntimeException(ex);
    }
  }
  return e;
}

Fixed version (ground truth):
private Entitlement addEntitlement(Consumer consumer,Pool pool,Integer quantity) throws EntitlementRefusedException {
  PreEntHelper preHelper=enforcer.pre(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(),quantity);
  consumer.addEntitlement(e);
  if (preHelper.getGrantFreeEntitlement()) {
    log.info("String_Node_Str");
    e.setIsFree(Boolean.TRUE);
  }
 else {
    pool.bumpConsumed(quantity);
  }
  postEntHelper.init(e);
  enforcer.post(postEntHelper,e);
  entitlementCurator.create(e);
  consumerCurator.update(consumer);
  Pool mergedPool=epCurator.merge(pool);
  Subscription sub=subAdapter.getSubscription(mergedPool.getSubscriptionId());
  if (sub == null) {
    log.warn("String_Node_Str" + pool.getId());
  }
 else {
    try {
      EntitlementCertificate cert=this.entCertAdapter.generateEntitlementCert(consumer,e,sub,sub.getProduct(),sub.getEndDate(),new BigInteger(serialCurator.getNextSerial().toString()));
      e.getCertificates().add(cert);
      this.entCertCurator.create(cert);
    }
 catch (    Exception ex) {
      throw new RuntimeException(ex);
    }
  }
  return e;
}
Program: 49578
Project: 49578
Buggy source:
@Transactional public void revokeEntitlement(Entitlement entitlement){
  if (!entitlement.isFree()) {
    entitlement.getPool().dockConsumed();
  }
  Consumer consumer=entitlement.getConsumer();
  consumer.removeEntitlement(entitlement);
  Event event=eventFactory.entitlementDeleted(entitlement);
  epCurator.merge(entitlement.getPool());
  entitlementCurator.delete(entitlement);
  sink.sendEvent(event);
}

Fixed version (ground truth):
@Transactional public void revokeEntitlement(Entitlement entitlement){
  if (!entitlement.isFree()) {
    Pool.dockConsumed(entitlement);
  }
  Consumer consumer=entitlement.getConsumer();
  consumer.removeEntitlement(entitlement);
  Event event=eventFactory.entitlementDeleted(entitlement);
  epCurator.merge(entitlement.getPool());
  entitlementCurator.delete(entitlement);
  sink.sendEvent(event);
}
Program: 49579
Project: 49579
Buggy source:
/** 
 * Increment consumed quantity by one.
 */
public void bumpConsumed(){
  this.consumed++;
}

Fixed version (ground truth):
public void bumpConsumed(int quantity){
  consumed+=quantity;
}
Program: 49580
Project: 49580
Buggy source:
public void dockConsumed(){
  this.consumed--;
}

Fixed version (ground truth):
public static void dockConsumed(Entitlement e){
  e.getPool().dockConsumed(e.getQuantity());
}
Program: 49581
Project: 49581
Buggy source:
@Test public void testGetSerialFiltering(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  List<EntitlementCertificate> serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),null);
  assertEquals(4,serials.size());
  BigInteger serial1=serials.get(0).getSerial();
  BigInteger serial2=serials.get(3).getSerial();
  String serialsToFilter=serial1.toString() + "String_Node_Str" + serial2.toString();
  serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),serialsToFilter);
  assertEquals(2,serials.size());
  assertEquals(serial1,serials.get(0).getSerial());
  assertEquals(serial2,serials.get(1).getSerial());
}

Fixed version (ground truth):
@Test public void testGetSerialFiltering(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  List<EntitlementCertificate> serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),null);
  assertEquals(4,serials.size());
  BigInteger serial1=serials.get(0).getSerial();
  BigInteger serial2=serials.get(3).getSerial();
  String serialsToFilter=serial1.toString() + "String_Node_Str" + serial2.toString();
  serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),serialsToFilter);
  assertEquals(2,serials.size());
  assertEquals(serial1,serials.get(0).getSerial());
  assertEquals(serial2,serials.get(1).getSerial());
}
Program: 49582
Project: 49582
Buggy source:
@Test public void bindByTokenPreExistingSubscription(){
  setupPrincipal(owner,Role.CONSUMER);
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Subscription sub=TestUtil.createSubscription(owner,prod);
  SubscriptionToken token=TestUtil.createSubscriptionToken();
  token.setSubscription(sub);
  subCurator.create(sub);
  subTokenCurator.create(token);
  poolCurator.refreshPools(owner);
  List<Pool> pools=poolCurator.listByOwnerAndProduct(owner,prod.getId());
  assertEquals(1,pools.size());
  List<Entitlement> ents=consumerResource.bind(consumer.getUuid(),null,token.getToken(),null,null,null,null);
  assertEquals(1,ents.size());
  assertEquals(sub.getId(),ents.get(0).getPool().getSubscriptionId());
  assertEquals(1,poolCurator.listByOwnerAndProduct(owner,prod.getId()).size());
}

Fixed version (ground truth):
@Test public void bindByTokenPreExistingSubscription(){
  setupPrincipal(owner,Role.CONSUMER);
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Subscription sub=TestUtil.createSubscription(owner,prod);
  SubscriptionToken token=TestUtil.createSubscriptionToken();
  token.setSubscription(sub);
  subCurator.create(sub);
  subTokenCurator.create(token);
  poolCurator.refreshPools(owner);
  List<Pool> pools=poolCurator.listByOwnerAndProduct(owner,prod.getId());
  assertEquals(1,pools.size());
  List<Entitlement> ents=consumerResource.bind(consumer.getUuid(),null,token.getToken(),null,1,null,null);
  assertEquals(1,ents.size());
  assertEquals(sub.getId(),ents.get(0).getPool().getSubscriptionId());
  assertEquals(1,poolCurator.listByOwnerAndProduct(owner,prod.getId()).size());
}
Program: 49583
Project: 49583
Buggy source:
@Test public void testCanGetOwnedConsumersCerts(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  setupPrincipal(new ConsumerPrincipal(consumer));
  assertEquals(3,consumerResource.getEntitlementCertificates(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void testCanGetOwnedConsumersCerts(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  setupPrincipal(new ConsumerPrincipal(consumer));
  assertEquals(3,consumerResource.getEntitlementCertificates(consumer.getUuid(),null).size());
}
Program: 49584
Project: 49584
Buggy source:
@Test public void unbindBySerialWithExistingCertificateShouldPass(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  List<EntitlementCertificate> serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),null);
  assertEquals(1,serials.size());
  consumerResource.unbindBySerial(consumer.getUuid(),serials.get(0).getSerial().longValue());
  assertEquals(0,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void unbindBySerialWithExistingCertificateShouldPass(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  List<EntitlementCertificate> serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),null);
  assertEquals(1,serials.size());
  consumerResource.unbindBySerial(consumer.getUuid(),serials.get(0).getSerial().longValue());
  assertEquals(0,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}
Program: 49585
Project: 49585
Buggy source:
@Test public void consumerShouldNotSeeAnotherConsumersEntitlements(){
  Consumer evilConsumer=TestUtil.createConsumer(standardSystemType,owner);
  consumerCurator.create(evilConsumer);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(evilConsumer.getUuid(),pool.getId(),null,null,null,null,null);
  setupPrincipal(new ConsumerPrincipal(evilConsumer));
  securityInterceptor.enable();
  crudInterceptor.enable();
  assertEquals(0,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void consumerShouldNotSeeAnotherConsumersEntitlements(){
  Consumer evilConsumer=TestUtil.createConsumer(standardSystemType,owner);
  consumerCurator.create(evilConsumer);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(evilConsumer.getUuid(),pool.getId(),null,null,1,null,null);
  setupPrincipal(new ConsumerPrincipal(evilConsumer));
  securityInterceptor.enable();
  crudInterceptor.enable();
  assertEquals(0,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}
Program: 49586
Project: 49586
Buggy source:
@Test public void testBindByPool() throws Exception {
  List<Entitlement> resultList=consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumer=consumerCurator.lookupByUuid(consumer.getUuid());
  assertEquals(1,consumer.getEntitlements().size());
  pool=poolCurator.find(pool.getId());
  assertEquals(new Long(1),pool.getConsumed());
  assertEquals(1,resultList.size());
  assertEquals(pool.getId(),resultList.get(0).getPool().getId());
  assertEquals(1,entCertCurator.listForEntitlement(resultList.get(0)).size());
}

Fixed version (ground truth):
@Test public void testBindByPool() throws Exception {
  List<Entitlement> resultList=consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumer=consumerCurator.lookupByUuid(consumer.getUuid());
  assertEquals(1,consumer.getEntitlements().size());
  pool=poolCurator.find(pool.getId());
  assertEquals(new Long(1),pool.getConsumed());
  assertEquals(1,resultList.size());
  assertEquals(pool.getId(),resultList.get(0).getPool().getId());
  assertEquals(1,entCertCurator.listForEntitlement(resultList.get(0)).size());
}
Program: 49587
Project: 49587
Buggy source:
@Test public void testGetCerts(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  List<EntitlementCertificate> serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),null);
  assertEquals(1,serials.size());
}

Fixed version (ground truth):
@Test public void testGetCerts(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  List<EntitlementCertificate> serials=consumerResource.getEntitlementCertificates(consumer.getUuid(),null);
  assertEquals(1,serials.size());
}
Program: 49588
Project: 49588
Buggy source:
@Test public void testCannotGetAnotherConsumersCerts(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  Consumer evilConsumer=TestUtil.createConsumer(standardSystemType,owner);
  consumerCurator.create(evilConsumer);
  setupPrincipal(new ConsumerPrincipal(evilConsumer));
  securityInterceptor.enable();
  crudInterceptor.enable();
  assertEquals(0,consumerResource.getEntitlementCertificates(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void testCannotGetAnotherConsumersCerts(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  Consumer evilConsumer=TestUtil.createConsumer(standardSystemType,owner);
  consumerCurator.create(evilConsumer);
  setupPrincipal(new ConsumerPrincipal(evilConsumer));
  securityInterceptor.enable();
  crudInterceptor.enable();
  assertEquals(0,consumerResource.getEntitlementCertificates(consumer.getUuid(),null).size());
}
Program: 49589
Project: 49589
Buggy source:
@Test public void testEntitle() throws Exception {
  consumerResource.bind(consumer.getUuid(),null,null,product.getId(),null,null,null);
  consumer=consumerCurator.lookupByUuid(consumer.getUuid());
  assertEquals(1,consumer.getEntitlements().size());
  pool=poolCurator.find(pool.getId());
  assertEquals(new Long(1),pool.getConsumed());
}

Fixed version (ground truth):
@Test public void testEntitle() throws Exception {
  consumerResource.bind(consumer.getUuid(),null,null,product.getId(),1,null,null);
  consumer=consumerCurator.lookupByUuid(consumer.getUuid());
  assertEquals(1,consumer.getEntitlements().size());
  pool=poolCurator.find(pool.getId());
  assertEquals(new Long(1),pool.getConsumed());
}
Program: 49590
Project: 49590
Buggy source:
@Test public void bindByTokenNewSubscription(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Subscription sub=TestUtil.createSubscription(owner,prod);
  SubscriptionToken token=TestUtil.createSubscriptionToken();
  token.setSubscription(sub);
  subCurator.create(sub);
  subTokenCurator.create(token);
  assertEquals(0,poolCurator.listByOwnerAndProduct(owner,prod.getId()).size());
  consumerResource.bind(consumer.getUuid(),null,token.getToken(),null,null,null,null);
  assertEquals(1,poolCurator.listByOwnerAndProduct(owner,prod.getId()).size());
}

Fixed version (ground truth):
@Test public void bindByTokenNewSubscription(){
  Product prod=TestUtil.createProduct();
  productCurator.create(prod);
  Subscription sub=TestUtil.createSubscription(owner,prod);
  SubscriptionToken token=TestUtil.createSubscriptionToken();
  token.setSubscription(sub);
  subCurator.create(sub);
  subTokenCurator.create(token);
  assertEquals(0,poolCurator.listByOwnerAndProduct(owner,prod.getId()).size());
  consumerResource.bind(consumer.getUuid(),null,token.getToken(),null,1,null,null);
  assertEquals(1,poolCurator.listByOwnerAndProduct(owner,prod.getId()).size());
}
Program: 49591
Project: 49591
Buggy source:
@Test public void testGetCertSerials(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  List<CertificateSerialDto> serials=consumerResource.getEntitlementCertificateSerials(consumer.getUuid());
  assertEquals(1,serials.size());
}

Fixed version (ground truth):
@Test public void testGetCertSerials(){
  Consumer consumer=createConsumer();
  List<EntitlementCertificate> certificates=createEntitlementCertificates();
  when(mockedEntitlementCertServiceAdapter.listForConsumer(consumer)).thenReturn(certificates);
  when(mockedConsumerCurator.lookupByUuid(consumer.getUuid())).thenReturn(consumer);
  ConsumerResource consumerResource=new ConsumerResource(mockedConsumerCurator,null,null,null,null,null,null,null,mockedEntitlementCertServiceAdapter,null,null,null,null,null);
  List<CertificateSerialDto> serials=consumerResource.getEntitlementCertificateSerials(consumer.getUuid());
  verifyCertificateSerialNumbers(serials);
}
Program: 49592
Project: 49592
Buggy source:
@Test public void consumerShouldSeeOwnEntitlements(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  setupPrincipal(new ConsumerPrincipal(consumer));
  securityInterceptor.enable();
  crudInterceptor.enable();
  assertEquals(3,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void consumerShouldSeeOwnEntitlements(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  setupPrincipal(new ConsumerPrincipal(consumer));
  securityInterceptor.enable();
  crudInterceptor.enable();
  assertEquals(3,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}
Program: 49593
Project: 49593
Buggy source:
@Test public void ownerShouldNotSeeOtherOwnerEntitlements(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  Owner evilOwner=ownerCurator.create(new Owner("String_Node_Str"));
  ownerCurator.create(evilOwner);
  securityInterceptor.enable();
  crudInterceptor.enable();
  setupPrincipal(evilOwner,Role.OWNER_ADMIN);
  assertEquals(0,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void ownerShouldNotSeeOtherOwnerEntitlements(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  Owner evilOwner=ownerCurator.create(new Owner("String_Node_Str"));
  ownerCurator.create(evilOwner);
  securityInterceptor.enable();
  crudInterceptor.enable();
  setupPrincipal(evilOwner,Role.OWNER_ADMIN);
  assertEquals(0,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}
Program: 49594
Project: 49594
Buggy source:
@Test public void ownerShouldSeeOwnEntitlements(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,null,null,null);
  securityInterceptor.enable();
  crudInterceptor.enable();
  setupPrincipal(owner,Role.OWNER_ADMIN);
  assertEquals(3,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}

Fixed version (ground truth):
@Test public void ownerShouldSeeOwnEntitlements(){
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  consumerResource.bind(consumer.getUuid(),pool.getId(),null,null,1,null,null);
  securityInterceptor.enable();
  crudInterceptor.enable();
  setupPrincipal(owner,Role.OWNER_ADMIN);
  assertEquals(3,consumerResource.listEntitlements(consumer.getUuid(),null).size());
}
Program: 49595
Project: 49595
Buggy source:
Principal getPrincipal(HttpRequest request) throws Exception {
  List<String> header=request.getHttpHeaders().getRequestHeader("String_Node_Str");
  String auth=null;
  if (null != header && header.size() > 0) {
    auth=header.get(0);
  }
  if (auth != null && auth.toUpperCase().startsWith("String_Node_Str")) {
    String userpassEncoded=auth.substring(6);
    String[] userpass=new String(Base64.decodeBase64(userpassEncoded)).split("String_Node_Str");
    String username=userpass[0];
    String password=userpass[1];
    log.debug("String_Node_Str" + username + "String_Node_Str"+ password);
    if (userServiceAdapter.validateUser(username,password)) {
      Principal principal=createPrincipal(username);
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + principal.getOwner().getDisplayName() + "String_Node_Str"+ username+ "String_Node_Str");
      }
      return principal;
    }
  }
  return null;
}

Fixed version (ground truth):
Principal getPrincipal(HttpRequest request) throws Exception {
  List<String> header=request.getHttpHeaders().getRequestHeader("String_Node_Str");
  String auth=null;
  if (null != header && header.size() > 0) {
    auth=header.get(0);
  }
  if (auth != null && auth.toUpperCase().startsWith("String_Node_Str")) {
    String userpassEncoded=auth.substring(6);
    String[] userpass=new String(Base64.decodeBase64(userpassEncoded)).split("String_Node_Str");
    String username=userpass[0];
    String password=userpass[1];
    log.debug("String_Node_Str" + username + "String_Node_Str"+ password.length()+ "String_Node_Str");
    if (userServiceAdapter.validateUser(username,password)) {
      Principal principal=createPrincipal(username);
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + principal.getOwner().getDisplayName() + "String_Node_Str"+ username+ "String_Node_Str");
      }
      return principal;
    }
  }
  return null;
}
Program: 49596
Project: 49596
Buggy source:
/** 
 * Check if this pool provides the given product ID.
 * @param productId
 * @return
 */
public Boolean provides(String productId){
  if (this.productId == productId) {
    return true;
  }
  return this.providedProductIds.contains(productId);
}

Fixed version (ground truth):
/** 
 * Check if this pool provides the given product ID.
 * @param productId
 * @return
 */
public Boolean provides(String productId){
  if (this.productId.equals(productId)) {
    return true;
  }
  return this.providedProductIds.contains(productId);
}
Program: 49597
Project: 49597
Buggy source:
public String toString(){
  return "String_Node_Str" + getId() + "String_Node_Str"+ owner.getId()+ "String_Node_Str"+ getProvidedProductIds()+ "String_Node_Str"+ getSubscriptionId()+ "String_Node_Str"+ getQuantity()+ "String_Node_Str"+ getEndDate()+ "String_Node_Str";
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + getId() + "String_Node_Str"+ owner.getId()+ "String_Node_Str"+ productId+ "String_Node_Str"+ getProvidedProductIds()+ "String_Node_Str"+ getSubscriptionId()+ "String_Node_Str"+ getQuantity()+ "String_Node_Str"+ getEndDate()+ "String_Node_Str";
}
Program: 49599
Project: 49599
Buggy source:
@SuppressWarnings("String_Node_Str") public List<Pool> listAvailableEntitlementPools(Consumer c,Owner o,String productId,boolean activeOnly){
  List<Pool> results=null;
  Criteria crit=currentSession().createCriteria(Pool.class);
  if (activeOnly) {
    crit.add(Restrictions.eq("String_Node_Str",Boolean.TRUE));
  }
  if (c != null) {
    crit.add(Restrictions.eq("String_Node_Str",c.getOwner()));
  }
  if (o != null) {
    crit.add(Restrictions.eq("String_Node_Str",o));
  }
  if (productId != null) {
    crit.add(Restrictions.eq("String_Node_Str",productId));
  }
  crit.add(Restrictions.lt("String_Node_Str",new Date()));
  crit.add(Restrictions.gt("String_Node_Str",new Date()));
  results=(List<Pool>)crit.list();
  if (results == null) {
    results=new ArrayList<Pool>();
  }
  if (c != null) {
    List<Pool> finalResults=new LinkedList<Pool>();
    for (    Pool p : results) {
      PreEntHelper helper=enforcer.pre(c,p);
      if (helper.getResult().isSuccessful()) {
        finalResults.add(p);
      }
 else {
        log.info("String_Node_Str" + p.getId());
        log.info(helper.getResult().getErrors());
      }
    }
    return finalResults;
  }
  return results;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public List<Pool> listAvailableEntitlementPools(Consumer c,Owner o,String productId,boolean activeOnly){
  log.debug("String_Node_Str");
  log.debug("String_Node_Str" + c);
  log.debug("String_Node_Str" + o);
  log.debug("String_Node_Str" + productId);
  List<Pool> results=null;
  Criteria crit=currentSession().createCriteria(Pool.class);
  if (activeOnly) {
    crit.add(Restrictions.eq("String_Node_Str",Boolean.TRUE));
  }
  if (c != null) {
    crit.add(Restrictions.eq("String_Node_Str",c.getOwner()));
  }
  if (o != null) {
    crit.add(Restrictions.eq("String_Node_Str",o));
  }
  if (productId != null) {
    crit.add(Restrictions.eq("String_Node_Str",productId));
  }
  crit.add(Restrictions.lt("String_Node_Str",new Date()));
  crit.add(Restrictions.gt("String_Node_Str",new Date()));
  results=(List<Pool>)crit.list();
  if (results == null) {
    log.debug("String_Node_Str");
    results=new ArrayList<Pool>();
  }
  if (c != null) {
    List<Pool> finalResults=new LinkedList<Pool>();
    for (    Pool p : results) {
      PreEntHelper helper=enforcer.pre(c,p);
      if (helper.getResult().isSuccessful()) {
        finalResults.add(p);
      }
 else {
        log.info("String_Node_Str" + p.getId());
        log.info(helper.getResult().getErrors());
      }
    }
    return finalResults;
  }
  return results;
}
Program: 49601
Project: 49601
Buggy source:
/** 
 * default constructor
 */
@Inject public ConsumerIdentityCertificateCurator(CertificateServiceAdapter certServiceAdapter){
  super(ConsumerIdentityCertificate.class);
  this.certServiceAdapter=certServiceAdapter;
}

Fixed version (ground truth):
/** 
 * default constructor
 */
@Inject public ConsumerIdentityCertificateCurator(){
  super(ConsumerIdentityCertificate.class);
}
Program: 49602
Project: 49602
Buggy source:
/** 
 * Create a Consumer
 * @param in Consumer metadata encapsulated in a ConsumerInfo.
 * @return newly created Consumer
 * @throws BadRequestException generic exception type for web services We are calling this "registerConsumer" in the api discussions
 */
@POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Consumer create(Consumer in) throws BadRequestException {
  Owner owner=ownerCurator.findAll().get(0);
  Consumer consumer=new Consumer();
  log.debug("String_Node_Str" + in.getType().getLabel());
  ConsumerType type=consumerTypeCurator.lookupByLabel(in.getType().getLabel());
  log.debug("String_Node_Str");
  log.debug(in.getFacts().getMetadata());
  for (  String key : in.getFacts().getMetadata().keySet()) {
    log.debug("String_Node_Str" + key + "String_Node_Str"+ in.getFact(key));
  }
  if (type == null) {
    throw new BadRequestException("String_Node_Str" + in.getType().getLabel());
  }
  try {
    consumer=consumerCurator.create(new Consumer(in,owner,type));
    ConsumerIdentityCertificate idCert=identityCertService.generateIdentityCert(consumer,this.username);
    log.debug("String_Node_Str" + idCert);
    if (idCert == null) {
      throw new RuntimeException("String_Node_Str");
    }
    ConsumerIdentityCertificate idCert=consumerIdCertCurator.getCert(consumer);
    consumer.setIdCert(idCert);
    return consumer;
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    throw new BadRequestException(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Create a Consumer
 * @param in Consumer metadata encapsulated in a ConsumerInfo.
 * @return newly created Consumer
 * @throws BadRequestException generic exception type for web services We are calling this "registerConsumer" in the api discussions
 */
@POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Consumer create(Consumer in) throws BadRequestException {
  Owner owner=ownerCurator.findAll().get(0);
  Consumer consumer=new Consumer();
  log.debug("String_Node_Str" + in.getType().getLabel());
  ConsumerType type=consumerTypeCurator.lookupByLabel(in.getType().getLabel());
  log.debug("String_Node_Str");
  log.debug(in.getFacts().getMetadata());
  for (  String key : in.getFacts().getMetadata().keySet()) {
    log.debug("String_Node_Str" + key + "String_Node_Str"+ in.getFact(key));
  }
  if (type == null) {
    throw new BadRequestException("String_Node_Str" + in.getType().getLabel());
  }
  try {
    consumer=consumerCurator.create(new Consumer(in,owner,type));
    ConsumerIdentityCertificate idCert=identityCertService.generateIdentityCert(consumer,this.username);
    log.debug("String_Node_Str" + idCert);
    if (idCert == null) {
      throw new RuntimeException("String_Node_Str");
    }
    consumer.setIdCert(idCert);
    return consumer;
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
    throw new BadRequestException(e.getMessage());
  }
}