Program: 49385
Project: 49385
Buggy source:
@Before public void setUp(){
  InputStream is=this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
  Rules rules=new Rules(Util.readFile(is));
  when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
  when(rulesCuratorMock.getRules()).thenReturn(rules);
  when(configMock.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
  poolRules=new PoolRules(poolManagerMock,configMock,entCurMock,productCuratorMock);
  principal=TestUtil.createOwnerPrincipal();
  owner=principal.getOwners().get(0);
  consumer=new Consumer("String_Node_Str","String_Node_Str",owner,new ConsumerType(ConsumerTypeEnum.SYSTEM));
  prod1=TestUtil.createProduct(owner);
  prod1.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  prod1.addAttribute(new ProductAttribute("String_Node_Str",STACK));
  prod1.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  when(productCuratorMock.find(prod1.getUuid())).thenReturn(prod1);
  prod2=TestUtil.createProduct(owner);
  prod2.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  prod2.addAttribute(new ProductAttribute("String_Node_Str",STACK));
  prod2.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  when(productCuratorMock.find(prod2.getUuid())).thenReturn(prod2);
  provided1=TestUtil.createProduct(owner);
  provided2=TestUtil.createProduct(owner);
  provided3=TestUtil.createProduct(owner);
  sub1=createStackedVirtSub(owner,prod1,TestUtil.createDate(2010,1,1),TestUtil.createDate(2015,1,1));
  sub1.getProvidedProducts().add(provided1);
  pool1=TestUtil.copyFromSub(sub1);
  sub2=createStackedVirtSub(owner,prod2,TestUtil.createDate(2011,1,1),TestUtil.createDate(2017,1,1));
  sub2.getProvidedProducts().add(provided2);
  pool2=TestUtil.copyFromSub(sub2);
  sub3=createStackedVirtSub(owner,prod2,TestUtil.createDate(2012,1,1),TestUtil.createDate(2020,1,1));
  sub3.getProvidedProducts().add(provided3);
  pool3=TestUtil.copyFromSub(sub3);
  stackedEnts.add(createEntFromPool(pool2));
  when(entCurMock.findByStackId(consumer,STACK)).thenReturn(stackedEnts);
  PoolHelper helper=new PoolHelper(poolManagerMock,stackedEnts.get(0));
  stackDerivedPool=helper.createHostRestrictedPool(prod2,pool2,"String_Node_Str");
}

Fixed version (ground truth):
@Before public void setUp(){
  InputStream is=this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
  Rules rules=new Rules(Util.readFile(is));
  when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
  when(rulesCuratorMock.getRules()).thenReturn(rules);
  when(configMock.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
  poolRules=new PoolRules(poolManagerMock,configMock,entCurMock,productCuratorMock);
  principal=TestUtil.createOwnerPrincipal();
  owner=principal.getOwners().get(0);
  consumer=new Consumer("String_Node_Str","String_Node_Str",owner,new ConsumerType(ConsumerTypeEnum.SYSTEM));
  prod1=TestUtil.createProduct("String_Node_Str","String_Node_Str",owner);
  prod1.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  prod1.addAttribute(new ProductAttribute("String_Node_Str",STACK));
  prod1.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  when(productCuratorMock.find(prod1.getUuid())).thenReturn(prod1);
  prod2=TestUtil.createProduct("String_Node_Str","String_Node_Str",owner);
  prod2.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  prod2.addAttribute(new ProductAttribute("String_Node_Str",STACK));
  prod2.addAttribute(new ProductAttribute("String_Node_Str","String_Node_Str"));
  when(productCuratorMock.find(prod2.getUuid())).thenReturn(prod2);
  provided1=TestUtil.createProduct(owner);
  provided2=TestUtil.createProduct(owner);
  provided3=TestUtil.createProduct(owner);
  sub1=createStackedVirtSub(owner,prod1,TestUtil.createDate(2010,1,1),TestUtil.createDate(2015,1,1));
  sub1.getProvidedProducts().add(provided1);
  pool1=TestUtil.copyFromSub(sub1);
  sub2=createStackedVirtSub(owner,prod2,TestUtil.createDate(2011,1,1),TestUtil.createDate(2017,1,1));
  sub2.getProvidedProducts().add(provided2);
  pool2=TestUtil.copyFromSub(sub2);
  sub3=createStackedVirtSub(owner,prod2,TestUtil.createDate(2012,1,1),TestUtil.createDate(2020,1,1));
  sub3.getProvidedProducts().add(provided3);
  pool3=TestUtil.copyFromSub(sub3);
  stackedEnts.add(createEntFromPool(pool2));
  when(entCurMock.findByStackId(consumer,STACK)).thenReturn(stackedEnts);
  PoolHelper helper=new PoolHelper(poolManagerMock,stackedEnts.get(0));
  stackDerivedPool=helper.createHostRestrictedPool(prod2,pool2,"String_Node_Str");
}