Program: 168816
Project: 168816
Buggy source:
private <T extends DocumentCorrelationView>void testCorrelation(Class<T> entityView,Integer batchSize){
  EntityViewConfiguration cfg=EntityViews.createDefaultConfiguration();
  cfg.addEntityView(entityView);
  cfg.addEntityView(DocumentRelatedView.class);
  EntityViewManager evm=cfg.createEntityViewManager(cbf,em.getEntityManagerFactory());
  CriteriaBuilder<Document> criteria=cbf.create(em,Document.class,"String_Node_Str").orderByAsc("String_Node_Str");
  EntityViewSetting<T,CriteriaBuilder<T>> setting=EntityViewSetting.create(entityView);
  if (batchSize != null) {
    setting.setProperty(ConfigurationProperties.DEFAULT_BATCH_SIZE + "String_Node_Str",batchSize);
  }
  CriteriaBuilder<T> cb=evm.applySetting(setting,criteria);
  List<T> results=cb.getResultList();
  assertEquals(4,results.size());
  assertEquals(doc1.getName(),results.get(0).getName());
  assertEquals(0,results.get(0).getOwnerRelatedDocuments().size());
  assertEquals(0,results.get(0).getOwnerRelatedDocumentIds().size());
  assertEquals(1,results.get(0).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc1.getName(),results.get(0).getOwnerOnlyRelatedDocuments());
  assertEquals(1,results.get(0).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc1.getId(),results.get(0).getOwnerOnlyRelatedDocumentIds());
  assertEquals(doc2.getName(),results.get(1).getName());
  assertEquals(2,results.get(1).getOwnerRelatedDocuments().size());
  assertRemovedByName(doc3.getName(),results.get(1).getOwnerRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(1).getOwnerRelatedDocuments());
  assertEquals(2,results.get(1).getOwnerRelatedDocumentIds().size());
  assertRemoved(doc3.getId(),results.get(1).getOwnerRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(1).getOwnerRelatedDocumentIds());
  assertEquals(3,results.get(1).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(1).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(1).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(1).getOwnerOnlyRelatedDocuments());
  assertEquals(3,results.get(1).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(1).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(1).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(1).getOwnerOnlyRelatedDocumentIds());
  assertEquals(doc3.getName(),results.get(2).getName());
  assertEquals(2,results.get(2).getOwnerRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(2).getOwnerRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(2).getOwnerRelatedDocuments());
  assertEquals(2,results.get(2).getOwnerRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(2).getOwnerRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(2).getOwnerRelatedDocumentIds());
  assertEquals(3,results.get(2).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(2).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(2).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(2).getOwnerOnlyRelatedDocuments());
  assertEquals(3,results.get(2).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(2).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(2).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(2).getOwnerOnlyRelatedDocumentIds());
  assertEquals(doc4.getName(),results.get(3).getName());
  assertEquals(2,results.get(3).getOwnerRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(3).getOwnerRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(3).getOwnerRelatedDocuments());
  assertEquals(2,results.get(3).getOwnerRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(3).getOwnerRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(3).getOwnerRelatedDocumentIds());
  assertEquals(3,results.get(3).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(3).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(3).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(3).getOwnerOnlyRelatedDocuments());
  assertEquals(3,results.get(3).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(3).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(3).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(3).getOwnerOnlyRelatedDocumentIds());
}

Fixed version (ground truth):
private <T extends DocumentCorrelationView>void testCorrelation(Class<T> entityView,Integer batchSize){
  EntityViewConfiguration cfg=EntityViews.createDefaultConfiguration();
  cfg.addEntityView(entityView);
  cfg.addEntityView(DocumentRelatedView.class);
  cfg.addEntityView(PersonSubView.class);
  EntityViewManager evm=cfg.createEntityViewManager(cbf,em.getEntityManagerFactory());
  CriteriaBuilder<Document> criteria=cbf.create(em,Document.class,"String_Node_Str").orderByAsc("String_Node_Str");
  EntityViewSetting<T,CriteriaBuilder<T>> setting=EntityViewSetting.create(entityView);
  if (batchSize != null) {
    setting.setProperty(ConfigurationProperties.DEFAULT_BATCH_SIZE + "String_Node_Str",batchSize);
  }
  CriteriaBuilder<T> cb=evm.applySetting(setting,criteria);
  List<T> results=cb.getResultList();
  assertEquals(4,results.size());
  assertEquals(doc1.getName(),results.get(0).getName());
  assertEquals(0,results.get(0).getOwnerRelatedDocuments().size());
  assertEquals(0,results.get(0).getOwnerRelatedDocumentIds().size());
  assertEquals(1,results.get(0).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc1.getName(),results.get(0).getOwnerOnlyRelatedDocuments());
  assertEquals(1,results.get(0).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc1.getId(),results.get(0).getOwnerOnlyRelatedDocumentIds());
  assertEquals(doc2.getName(),results.get(1).getName());
  assertEquals(2,results.get(1).getOwnerRelatedDocuments().size());
  assertRemovedByName(doc3.getName(),results.get(1).getOwnerRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(1).getOwnerRelatedDocuments());
  assertEquals(2,results.get(1).getOwnerRelatedDocumentIds().size());
  assertRemoved(doc3.getId(),results.get(1).getOwnerRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(1).getOwnerRelatedDocumentIds());
  assertEquals(3,results.get(1).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(1).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(1).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(1).getOwnerOnlyRelatedDocuments());
  assertEquals(3,results.get(1).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(1).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(1).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(1).getOwnerOnlyRelatedDocumentIds());
  assertEquals(doc3.getName(),results.get(2).getName());
  assertEquals(2,results.get(2).getOwnerRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(2).getOwnerRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(2).getOwnerRelatedDocuments());
  assertEquals(2,results.get(2).getOwnerRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(2).getOwnerRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(2).getOwnerRelatedDocumentIds());
  assertEquals(3,results.get(2).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(2).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(2).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(2).getOwnerOnlyRelatedDocuments());
  assertEquals(3,results.get(2).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(2).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(2).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(2).getOwnerOnlyRelatedDocumentIds());
  assertEquals(doc4.getName(),results.get(3).getName());
  assertEquals(2,results.get(3).getOwnerRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(3).getOwnerRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(3).getOwnerRelatedDocuments());
  assertEquals(2,results.get(3).getOwnerRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(3).getOwnerRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(3).getOwnerRelatedDocumentIds());
  assertEquals(3,results.get(3).getOwnerOnlyRelatedDocuments().size());
  assertRemovedByName(doc2.getName(),results.get(3).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc3.getName(),results.get(3).getOwnerOnlyRelatedDocuments());
  assertRemovedByName(doc4.getName(),results.get(3).getOwnerOnlyRelatedDocuments());
  assertEquals(3,results.get(3).getOwnerOnlyRelatedDocumentIds().size());
  assertRemoved(doc2.getId(),results.get(3).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc3.getId(),results.get(3).getOwnerOnlyRelatedDocumentIds());
  assertRemoved(doc4.getId(),results.get(3).getOwnerOnlyRelatedDocumentIds());
}