Program: 97424
Project: 97424
Buggy source:
/** 
 * Create<br> 1) PeerToPeer in Prepare state w Joe Smith assignee<br> 2) PeerToPeer in Review state w Joe Smith assignee and 2 reviewers<br> 3) PeerToPeer in Prepare state w Joe Smith assignee and completed<br> <br>
 */
public static void createPeerToPeerReviews(boolean DEBUG,SkynetTransaction transaction) throws Exception {
  if (DEBUG) {
    OseeLog.log(Activator.class,Level.INFO,"String_Node_Str");
  }
  TeamWorkFlowArtifact firstCodeArt=DemoDbUtil.getSampleCodeWorkflows().get(0);
  TeamWorkFlowArtifact secondCodeArt=DemoDbUtil.getSampleCodeWorkflows().get(1);
  PeerToPeerReviewArtifact reviewArt=PeerToPeerReviewManager.createNewPeerToPeerReview(firstCodeArt,"String_Node_Str",firstCodeArt.getStateMgr().getCurrentStateName(),transaction);
  reviewArt.persist(transaction);
  reviewArt=PeerToPeerReviewManager.createNewPeerToPeerReview(firstCodeArt,"String_Node_Str",firstCodeArt.getStateMgr().getCurrentStateName(),transaction);
  List<UserRole> roles=new ArrayList<UserRole>();
  roles.add(new UserRole(Role.Author,AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith)));
  roles.add(new UserRole(Role.Reviewer,AtsUsersClient.getUserFromToken(DemoUsers.Kay_Jones)));
  roles.add(new UserRole(Role.Reviewer,AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay),2.0,true));
  Result result=PeerToPeerReviewManager.transitionTo(reviewArt,PeerToPeerReviewState.Review,roles,null,AtsUsersClient.getUser(),false,transaction);
  if (result.isFalse()) {
    throw new IllegalStateException("String_Node_Str" + result.getText());
  }
  reviewArt.persist(transaction);
  reviewArt=PeerToPeerReviewManager.createNewPeerToPeerReview(secondCodeArt,"String_Node_Str",secondCodeArt.getStateMgr().getCurrentStateName(),new Date(),AtsUsersClient.getUserFromOseeUser(DemoDbUtil.getDemoUser(DemoUsers.Kay_Jones)),transaction);
  roles=new ArrayList<UserRole>();
  roles.add(new UserRole(Role.Author,AtsUsersClient.getUserFromToken(DemoUsers.Kay_Jones),2.3,true));
  roles.add(new UserRole(Role.Reviewer,AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith),4.5,true));
  roles.add(new UserRole(Role.Reviewer,AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay),2.0,true));
  List<ReviewDefectItem> defects=new ArrayList<ReviewDefectItem>();
  defects.add(new ReviewDefectItem(AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay),Severity.Issue,Disposition.Accept,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay),Severity.Issue,Disposition.Accept,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsUsersClient.getUserFromToken(DemoUsers.Alex_Kay),Severity.Major,Disposition.Reject,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith),Severity.Minor,Disposition.Reject,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsUsersClient.getUserFromToken(DemoUsers.Joe_Smith),Severity.Major,Disposition.Accept,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  for (  ReviewDefectItem defect : defects) {
    defect.setClosed(true);
  }
  result=PeerToPeerReviewManager.transitionTo(reviewArt,PeerToPeerReviewState.Completed,roles,defects,AtsUsersClient.getUser(),false,transaction);
  if (result.isTrue()) {
    reviewArt.persist(transaction);
  }
  if (result.isFalse()) {
    throw new IllegalStateException("String_Node_Str" + result.getText());
  }
}

Fixed version (ground truth):
/** 
 * Create<br> 1) PeerToPeer in Prepare state w Joe Smith assignee<br> 2) PeerToPeer in Review state w Joe Smith assignee and 2 reviewers<br> 3) PeerToPeer in Prepare state w Joe Smith assignee and completed<br> <br>
 */
public static void createPeerToPeerReviews(boolean DEBUG,SkynetTransaction transaction) throws Exception {
  if (DEBUG) {
    OseeLog.log(Activator.class,Level.INFO,"String_Node_Str");
  }
  TeamWorkFlowArtifact firstCodeArt=DemoDbUtil.getSampleCodeWorkflows().get(0);
  TeamWorkFlowArtifact secondCodeArt=DemoDbUtil.getSampleCodeWorkflows().get(1);
  PeerToPeerReviewArtifact reviewArt=PeerToPeerReviewManager.createNewPeerToPeerReview(firstCodeArt,"String_Node_Str",firstCodeArt.getStateMgr().getCurrentStateName(),transaction);
  reviewArt.persist(transaction);
  reviewArt=PeerToPeerReviewManager.createNewPeerToPeerReview(firstCodeArt,"String_Node_Str",firstCodeArt.getStateMgr().getCurrentStateName(),transaction);
  List<UserRole> roles=new ArrayList<UserRole>();
  roles.add(new UserRole(Role.Author,AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Joe_Smith)));
  roles.add(new UserRole(Role.Reviewer,AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Kay_Jones)));
  roles.add(new UserRole(Role.Reviewer,AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay),2.0,true));
  Result result=PeerToPeerReviewManager.transitionTo(reviewArt,PeerToPeerReviewState.Review,roles,null,AtsClientService.get().getUserAdmin().getCurrentUser(),false,transaction);
  if (result.isFalse()) {
    throw new IllegalStateException("String_Node_Str" + result.getText());
  }
  reviewArt.persist(transaction);
  reviewArt=PeerToPeerReviewManager.createNewPeerToPeerReview(secondCodeArt,"String_Node_Str",secondCodeArt.getStateMgr().getCurrentStateName(),new Date(),AtsClientService.get().getUserAdmin().getUserFromOseeUser(DemoDbUtil.getDemoUser(DemoUsers.Kay_Jones)),transaction);
  roles=new ArrayList<UserRole>();
  roles.add(new UserRole(Role.Author,AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Kay_Jones),2.3,true));
  roles.add(new UserRole(Role.Reviewer,AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Joe_Smith),4.5,true));
  roles.add(new UserRole(Role.Reviewer,AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay),2.0,true));
  List<ReviewDefectItem> defects=new ArrayList<ReviewDefectItem>();
  defects.add(new ReviewDefectItem(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay),Severity.Issue,Disposition.Accept,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay),Severity.Issue,Disposition.Accept,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Alex_Kay),Severity.Major,Disposition.Reject,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Joe_Smith),Severity.Minor,Disposition.Reject,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  defects.add(new ReviewDefectItem(AtsClientService.get().getUserAdmin().getUserFromToken(DemoUsers.Joe_Smith),Severity.Major,Disposition.Accept,InjectionActivity.Code,"String_Node_Str","String_Node_Str","String_Node_Str",new Date()));
  for (  ReviewDefectItem defect : defects) {
    defect.setClosed(true);
  }
  result=PeerToPeerReviewManager.transitionTo(reviewArt,PeerToPeerReviewState.Completed,roles,defects,AtsClientService.get().getUserAdmin().getCurrentUser(),false,transaction);
  if (result.isTrue()) {
    reviewArt.persist(transaction);
  }
  if (result.isFalse()) {
    throw new IllegalStateException("String_Node_Str" + result.getText());
  }
}