Program: 49205
Project: 49205
Buggy source:
@Test public void refreshPoolsCreatingPoolsForExistingSubscriptions(){
  List<Subscription> subscriptions=Util.newList();
  List<Pool> pools=Util.newList();
  Owner owner=this.getOwner();
  Product product=TestUtil.createProduct();
  product.setLocked(true);
  Subscription s=TestUtil.createSubscription(owner,product);
  subscriptions.add(s);
  mockSubsList(subscriptions);
  mockPoolsList(pools);
  List<Pool> newPools=new LinkedList<Pool>();
  Pool p=TestUtil.createPool(product);
  p.setId("String_Node_Str");
  p.setSourceSubscription(new SourceSubscription(s.getId(),"String_Node_Str"));
  newPools.add(p);
  ArgumentCaptor<Pool> argPool=ArgumentCaptor.forClass(Pool.class);
  when(poolRulesMock.createAndEnrichPools(argPool.capture(),any(List.class))).thenReturn(newPools);
  when(mockOwnerCurator.lookupByKey(owner.getKey())).thenReturn(owner);
  this.mockProducts(owner,product);
  this.mockProductImport(owner,product);
  this.mockContentImport(owner,new Content[]{});
  CandlepinQuery<Pool> cqmock=mock(CandlepinQuery.class);
  when(cqmock.list()).thenReturn(pools);
  when(cqmock.iterator()).thenReturn(pools.iterator());
  when(mockPoolCurator.listByOwnerAndType(eq(owner),any(PoolType.class))).thenReturn(cqmock);
  cqmock=mock(CandlepinQuery.class);
  when(cqmock.list()).thenReturn(Collections.<Pool>emptyList());
  when(mockPoolCurator.getPoolsBySubscriptionIds(anyList())).thenReturn(cqmock);
  cqmock=mock(CandlepinQuery.class);
  when(cqmock.list()).thenReturn(Collections.<Pool>emptyList());
  when(mockPoolCurator.getPoolsBySubscriptionId(anyString())).thenReturn(cqmock);
  this.manager.getRefresher(mockSubAdapter,mockOwnerAdapter).add(owner).run();
  TestUtil.assertPoolsAreEqual(TestUtil.copyFromSub(s),argPool.getValue());
  verify(this.mockPoolCurator,times(1)).create(any(Pool.class));
}

Fixed version (ground truth):
@Test public void refreshPoolsCreatingPoolsForExistingSubscriptions(){
  List<Subscription> subscriptions=Util.newList();
  List<Pool> pools=Util.newList();
  Owner owner=this.getOwner();
  Product product=TestUtil.createProduct();
  product.setLocked(true);
  Subscription s=TestUtil.createSubscription(owner,product);
  subscriptions.add(s);
  mockSubsList(subscriptions);
  mockPoolsList(pools);
  List<Pool> newPools=new LinkedList<Pool>();
  Pool p=TestUtil.createPool(product);
  p.setSourceSubscription(new SourceSubscription(s.getId(),"String_Node_Str"));
  newPools.add(p);
  ArgumentCaptor<Pool> argPool=ArgumentCaptor.forClass(Pool.class);
  when(poolRulesMock.createAndEnrichPools(argPool.capture(),any(List.class))).thenReturn(newPools);
  when(mockOwnerCurator.lookupByKey(owner.getKey())).thenReturn(owner);
  this.mockProducts(owner,product);
  this.mockProductImport(owner,product);
  this.mockContentImport(owner,new Content[]{});
  CandlepinQuery<Pool> cqmock=mock(CandlepinQuery.class);
  when(cqmock.list()).thenReturn(pools);
  when(cqmock.iterator()).thenReturn(pools.iterator());
  when(mockPoolCurator.listByOwnerAndType(eq(owner),any(PoolType.class))).thenReturn(cqmock);
  cqmock=mock(CandlepinQuery.class);
  when(cqmock.list()).thenReturn(Collections.<Pool>emptyList());
  when(mockPoolCurator.getPoolsBySubscriptionIds(anyList())).thenReturn(cqmock);
  cqmock=mock(CandlepinQuery.class);
  when(cqmock.list()).thenReturn(Collections.<Pool>emptyList());
  when(mockPoolCurator.getPoolsBySubscriptionId(anyString())).thenReturn(cqmock);
  this.manager.getRefresher(mockSubAdapter,mockOwnerAdapter).add(owner).run();
  TestUtil.assertPoolsAreEqual(TestUtil.copyFromSub(s),argPool.getValue());
  verify(this.mockPoolCurator,times(1)).create(any(Pool.class));
}