Program: 97578
Project: 97578
Buggy source:
/** 
 * Clear workDef from cache, clear all objects and create new objects with postFixName in titles
 */
private static void reset(String postFixName) throws OseeCoreException {
  AtsTestUtil.postFixName=postFixName;
  SkynetTransaction transaction=TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(),AtsTestUtil.class.getSimpleName());
  workDef=new MockWorkDefinition(WORK_DEF_NAME);
  analyze=new MockStateDefinition("String_Node_Str");
  analyze.setWorkDefinition(workDef);
  analyze.setStateType(StateType.Working);
  analyze.setOrdinal(1);
  workDef.addState(analyze);
  workDef.setStartState(analyze);
  implement=new MockStateDefinition("String_Node_Str");
  implement.setWorkDefinition(workDef);
  implement.setStateType(StateType.Working);
  implement.setOrdinal(2);
  workDef.addState(implement);
  completed=new MockStateDefinition("String_Node_Str");
  completed.setWorkDefinition(workDef);
  completed.setStateType(StateType.Completed);
  completed.setOrdinal(3);
  workDef.addState(completed);
  cancelled=new MockStateDefinition("String_Node_Str");
  cancelled.setWorkDefinition(workDef);
  cancelled.setStateType(StateType.Cancelled);
  cancelled.setOrdinal(4);
  workDef.addState(cancelled);
  analyze.setDefaultToState(implement);
  analyze.getToStates().addAll(Arrays.asList(implement,completed,cancelled));
  analyze.getOverrideAttributeValidationStates().addAll(Arrays.asList(cancelled));
  implement.setDefaultToState(completed);
  implement.getToStates().addAll(Arrays.asList(analyze,completed,cancelled));
  implement.getOverrideAttributeValidationStates().addAll(Arrays.asList(cancelled,analyze));
  completed.setDefaultToState(completed);
  completed.getToStates().addAll(Arrays.asList(implement));
  completed.getOverrideAttributeValidationStates().addAll(Arrays.asList(implement));
  cancelled.getToStates().addAll(Arrays.asList(analyze,implement));
  cancelled.getOverrideAttributeValidationStates().addAll(Arrays.asList(analyze,implement));
  estHoursWidgetDef=new MockWidgetDefinition(AtsAttributeTypes.EstimatedHours.getUnqualifiedName());
  estHoursWidgetDef.setAttributeName(AtsAttributeTypes.EstimatedHours.getName());
  estHoursWidgetDef.setXWidgetName("String_Node_Str");
  workPackageWidgetDef=new MockWidgetDefinition(AtsAttributeTypes.WorkPackage.getUnqualifiedName());
  workPackageWidgetDef.setAttributeName(AtsAttributeTypes.WorkPackage.getName());
  workPackageWidgetDef.setXWidgetName("String_Node_Str");
  WorkDefinitionFactory.addWorkDefinition(workDef);
  testAi=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi.setActive(true);
  testAi.setActionable(true);
  testAi2=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi2.setActive(true);
  testAi2.setActionable(true);
  testAi3=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi3.setActive(true);
  testAi3.setActionable(true);
  testAi4=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi4.setActive(true);
  testAi4.setActionable(true);
  teamDef=AtsConfigCache.instance.getTeamDefinitionFactory().createTeamDefinition(GUID.create(),getTitle("String_Node_Str",postFixName));
  teamDef.setWorkflowDefinition(WORK_DEF_NAME);
  teamDef.setActive(true);
  teamDef.setTeamUsesVersions(true);
  teamDef.getLeads().add(AtsUsersClient.getUser());
  testAi.setTeamDefinition(teamDef);
  testAi2.setTeamDefinition(teamDef);
  testAi3.setTeamDefinition(teamDef);
  testAi4.setTeamDefinition(teamDef);
  verArt1=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName),GUID.create(),HumanReadableId.generate());
  teamDef.getVersions().add(verArt1);
  verArt2=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName));
  teamDef.getVersions().add(verArt2);
  verArt3=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName));
  teamDef.getVersions().add(verArt3);
  verArt4=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName));
  teamDef.getVersions().add(verArt4);
  actionArt=ActionManager.createAction(null,getTitle("String_Node_Str",postFixName),"String_Node_Str",ChangeType.Improvement,"String_Node_Str",false,null,Arrays.asList(testAi),new Date(),AtsUsersClient.getUser(),null,transaction);
  teamArt=actionArt.getFirstTeam();
  teamArt.persist(transaction);
  actionArt.persist(transaction);
  transaction.execute();
}

Fixed version (ground truth):
/** 
 * Clear workDef from cache, clear all objects and create new objects with postFixName in titles
 */
private static void reset(String postFixName) throws OseeCoreException {
  AtsBulkLoad.reloadConfig(true);
  AtsTestUtil.postFixName=postFixName;
  SkynetTransaction transaction=TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(),AtsTestUtil.class.getSimpleName());
  workDef=new MockWorkDefinition(WORK_DEF_NAME);
  analyze=new MockStateDefinition("String_Node_Str");
  analyze.setWorkDefinition(workDef);
  analyze.setStateType(StateType.Working);
  analyze.setOrdinal(1);
  workDef.addState(analyze);
  workDef.setStartState(analyze);
  implement=new MockStateDefinition("String_Node_Str");
  implement.setWorkDefinition(workDef);
  implement.setStateType(StateType.Working);
  implement.setOrdinal(2);
  workDef.addState(implement);
  completed=new MockStateDefinition("String_Node_Str");
  completed.setWorkDefinition(workDef);
  completed.setStateType(StateType.Completed);
  completed.setOrdinal(3);
  workDef.addState(completed);
  cancelled=new MockStateDefinition("String_Node_Str");
  cancelled.setWorkDefinition(workDef);
  cancelled.setStateType(StateType.Cancelled);
  cancelled.setOrdinal(4);
  workDef.addState(cancelled);
  analyze.setDefaultToState(implement);
  analyze.getToStates().addAll(Arrays.asList(implement,completed,cancelled));
  analyze.getOverrideAttributeValidationStates().addAll(Arrays.asList(cancelled));
  implement.setDefaultToState(completed);
  implement.getToStates().addAll(Arrays.asList(analyze,completed,cancelled));
  implement.getOverrideAttributeValidationStates().addAll(Arrays.asList(cancelled,analyze));
  completed.setDefaultToState(completed);
  completed.getToStates().addAll(Arrays.asList(implement));
  completed.getOverrideAttributeValidationStates().addAll(Arrays.asList(implement));
  cancelled.getToStates().addAll(Arrays.asList(analyze,implement));
  cancelled.getOverrideAttributeValidationStates().addAll(Arrays.asList(analyze,implement));
  estHoursWidgetDef=new MockWidgetDefinition(AtsAttributeTypes.EstimatedHours.getUnqualifiedName());
  estHoursWidgetDef.setAttributeName(AtsAttributeTypes.EstimatedHours.getName());
  estHoursWidgetDef.setXWidgetName("String_Node_Str");
  workPackageWidgetDef=new MockWidgetDefinition(AtsAttributeTypes.WorkPackage.getUnqualifiedName());
  workPackageWidgetDef.setAttributeName(AtsAttributeTypes.WorkPackage.getName());
  workPackageWidgetDef.setXWidgetName("String_Node_Str");
  WorkDefinitionFactory.addWorkDefinition(workDef);
  testAi=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi.setActive(true);
  testAi.setActionable(true);
  AtsConfigCache.instance.cache(testAi);
  testAi2=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi2.setActive(true);
  testAi2.setActionable(true);
  AtsConfigCache.instance.cache(testAi2);
  testAi3=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi3.setActive(true);
  testAi3.setActionable(true);
  AtsConfigCache.instance.cache(testAi3);
  testAi4=AtsConfigCache.instance.getActionableItemFactory().createActionableItem(GUID.create(),getTitle("String_Node_Str",postFixName));
  testAi4.setActive(true);
  testAi4.setActionable(true);
  AtsConfigCache.instance.cache(testAi4);
  teamDef=AtsConfigCache.instance.getTeamDefinitionFactory().createTeamDefinition(GUID.create(),getTitle("String_Node_Str",postFixName));
  teamDef.setWorkflowDefinition(WORK_DEF_NAME);
  teamDef.setActive(true);
  teamDef.setTeamUsesVersions(true);
  teamDef.getLeads().add(AtsUsersClient.getUser());
  AtsConfigCache.instance.cache(teamDef);
  testAi.setTeamDefinition(teamDef);
  testAi2.setTeamDefinition(teamDef);
  testAi3.setTeamDefinition(teamDef);
  testAi4.setTeamDefinition(teamDef);
  verArt1=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName),GUID.create(),HumanReadableId.generate());
  teamDef.getVersions().add(verArt1);
  AtsConfigCache.instance.cache(verArt1);
  verArt2=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName));
  teamDef.getVersions().add(verArt2);
  AtsConfigCache.instance.cache(verArt2);
  verArt3=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName));
  teamDef.getVersions().add(verArt3);
  AtsConfigCache.instance.cache(verArt3);
  verArt4=AtsConfigCache.instance.getVersionFactory().createVersion(getTitle("String_Node_Str",postFixName));
  teamDef.getVersions().add(verArt4);
  AtsConfigCache.instance.cache(verArt4);
  actionArt=ActionManager.createAction(null,getTitle("String_Node_Str",postFixName),"String_Node_Str",ChangeType.Improvement,"String_Node_Str",false,null,Arrays.asList(testAi),new Date(),AtsUsersClient.getUser(),null,transaction);
  teamArt=actionArt.getFirstTeam();
  teamArt.persist(transaction);
  actionArt.persist(transaction);
  transaction.execute();
}