Program: 136368
Project: 136368
Buggy source:
@Before public void runBeforeEachTest() throws LibrarySaveException, RepositoryException {
  xsdStringNode=NodeFinders.findNodeByName("String_Node_Str",Node.XSD_NAMESPACE);
  ProjectNode uploadProject=createProject("String_Node_Str",getRepositoryForTest(),"String_Node_Str");
  majorLibrary=LibraryNodeBuilder.create("String_Node_Str",getRepositoryForTest().getNamespace() + "String_Node_Str","String_Node_Str",new Version(1,0,0)).build(uploadProject,pc);
  secondLib=LibraryNodeBuilder.create("String_Node_Str",getRepositoryForTest().getNamespace() + "String_Node_Str","String_Node_Str",new Version(1,0,0)).build(uploadProject,pc);
  chain=rc.manage(getRepositoryForTest(),Collections.singletonList(majorLibrary)).get(0);
  boolean locked=rc.lock(chain.getHead());
  Assert.assertTrue(locked);
  Assert.assertTrue(majorLibrary.isEditable());
  Assert.assertEquals(RepositoryItemState.MANAGED_WIP,chain.getHead().getProjectItem().getState());
  sbo=ml.addBusinessObjectToLibrary(secondLib,"String_Node_Str");
  bo=ml.addBusinessObjectToLibrary(majorLibrary,"String_Node_Str");
  co=ml.addCoreObjectToLibrary(majorLibrary,"String_Node_Str");
  bo.setExtensible(true);
  vwa=ml.addVWA_ToLibrary(majorLibrary,"String_Node_Str");
  ml.addSimpleTypeToLibrary(majorLibrary,"String_Node_Str");
  ml.addClosedEnumToLibrary(majorLibrary,"String_Node_Str");
  ml.addOpenEnumToLibrary(majorLibrary,"String_Node_Str");
  ml.addNestedTypes(majorLibrary);
  core2=(CoreObjectNode)majorLibrary.findNodeByName("String_Node_Str");
  ServiceNode svc=new ServiceNode(bo);
  svc.setName(bo.getName() + "String_Node_Str");
  ExtensionPointNode ep=new ExtensionPointNode(new TLExtensionPointFacet());
  ep.setExtendsType(sbo.getSummaryFacet());
  majorLibrary.addMember(ep);
  Assert.assertTrue(majorLibrary.isValid());
  TotalDescendents=11;
  TotalLibraries=3;
  ActiveComplex=8;
  ActiveSimple=2;
  MinorComplex=0;
  patchLibrary=rc.createPatchVersion(chain.getHead());
  ml.addSimpleTypeToLibrary(patchLibrary,"String_Node_Str");
  TotalDescendents+=1;
  ActiveSimple+=1;
  Assert.assertTrue(chain.isValid());
  checkCounts(chain);
  ExtensionPointNode ePatch=new ExtensionPointNode(new TLExtensionPointFacet());
  patchLibrary.addMember(ePatch);
  ePatch.setExtendsType(core2.getSummaryFacet());
  ePatch.addProperty(new IndicatorNode(ePatch,"String_Node_Str"));
  TotalDescendents+=1;
  ActiveComplex+=1;
  Assert.assertTrue(chain.isValid());
  checkCounts(chain);
  minorLibrary=rc.createMinorVersion(chain.getHead());
  MinorComplex++;
  TotalDescendents++;
  Assert.assertTrue(patchLibrary.getComplexRoot().getChildren().contains(ePatch.getParent()));
  mCo=null;
  for (  Node n : minorLibrary.getDescendants_NamedTypes()) {
    if (n.getName().equals(core2.getName())) {
      mCo=(CoreObjectNode)n;
      break;
    }
  }
  Assert.assertSame(core2,mCo.getExtendsType());
  if (!(mCo.getParent() instanceof VersionNode)) {
    VersionNode vn=new VersionNode(mCo);
    ((AggregateNode)chain.getComplexAggregate()).add(mCo);
  }
  checkCounts(chain);
  Assert.assertTrue(chain.isValid());
}

Fixed version (ground truth):
@Before public void runBeforeEachTest() throws LibrarySaveException, RepositoryException {
  xsdStringNode=NodeFinders.findNodeByName("String_Node_Str",Node.XSD_NAMESPACE);
  ProjectNode uploadProject=createProject("String_Node_Str",getRepositoryForTest(),"String_Node_Str");
  majorLibrary=LibraryNodeBuilder.create("String_Node_Str",getRepositoryForTest().getNamespace() + "String_Node_Str","String_Node_Str",new Version(1,0,0)).build(uploadProject,pc);
  secondLib=LibraryNodeBuilder.create("String_Node_Str",getRepositoryForTest().getNamespace() + "String_Node_Str","String_Node_Str",new Version(1,0,0)).build(uploadProject,pc);
  chain=rc.manage(getRepositoryForTest(),Collections.singletonList(majorLibrary)).get(0);
  boolean locked=rc.lock(chain.getHead());
  Assert.assertTrue(locked);
  Assert.assertTrue(majorLibrary.isEditable());
  Assert.assertEquals(RepositoryItemState.MANAGED_WIP,chain.getHead().getProjectItem().getState());
  sbo=ml.addBusinessObjectToLibrary(secondLib,"String_Node_Str");
  bo=ml.addBusinessObjectToLibrary(majorLibrary,"String_Node_Str");
  co=ml.addCoreObjectToLibrary(majorLibrary,"String_Node_Str");
  bo.setExtensible(true);
  vwa=ml.addVWA_ToLibrary(majorLibrary,"String_Node_Str");
  ml.addSimpleTypeToLibrary(majorLibrary,"String_Node_Str");
  ml.addClosedEnumToLibrary(majorLibrary,"String_Node_Str");
  ml.addOpenEnumToLibrary(majorLibrary,"String_Node_Str");
  ml.addNestedTypes(majorLibrary);
  core2=(CoreObjectNode)majorLibrary.findNodeByName("String_Node_Str");
  ServiceNode svc=new ServiceNode(bo);
  svc.setName(bo.getName() + "String_Node_Str");
  ExtensionPointNode ep=new ExtensionPointNode(new TLExtensionPointFacet());
  ep.setExtendsType(sbo.getSummaryFacet());
  majorLibrary.addMember(ep);
  Assert.assertTrue(majorLibrary.isValid());
  TotalDescendents=11;
  TotalLibraries=3;
  ActiveComplex=8;
  ActiveSimple=2;
  MinorComplex=0;
  patchLibrary=rc.createPatchVersion(chain.getHead());
  ml.addSimpleTypeToLibrary(patchLibrary,"String_Node_Str");
  TotalDescendents+=1;
  ActiveSimple+=1;
  Assert.assertTrue(chain.isValid());
  checkCounts(chain);
  ExtensionPointNode ePatch=new ExtensionPointNode(new TLExtensionPointFacet());
  patchLibrary.addMember(ePatch);
  ePatch.setExtendsType(core2.getSummaryFacet());
  ePatch.addProperty(new IndicatorNode(ePatch,"String_Node_Str"));
  TotalDescendents+=1;
  ActiveComplex+=1;
  Assert.assertTrue(chain.isValid());
  checkCounts(chain);
  minorLibrary=rc.createMinorVersion(chain.getHead());
  MinorComplex++;
  TotalDescendents++;
  TotalDescendents++;
  Assert.assertSame(((VersionNode)patchLibrary.getComplexRoot().getChildren().get(0)).getNewestVersion(),ePatch);
  checkCounts(chain);
  mCo=null;
  for (  Node n : minorLibrary.getDescendants_NamedTypes()) {
    if (n.getName().equals(core2.getName())) {
      mCo=(CoreObjectNode)n;
      break;
    }
  }
  Assert.assertSame(core2,mCo.getExtendsType());
  checkCounts(chain);
  Assert.assertTrue(chain.isValid());
}