@Test
 public void testCreateNewLeader() {
   PRInfo pr = new PRInfo((long) 1, DEFAULT_DATE, Role.AUTHOR);
   pr.setId(2);
   pr.setDate(1217354708206L);
   pr.setRole(Role.APPROVER);
   assertEquals(2, pr.getId());
   assertEquals(1217354708206L, pr.getDate());
   assertEquals(Role.APPROVER, pr.getRole());
   assertEquals(2, pr.getRole().getPosition());
 }
  public JSONObject convertLeadersToJson(List<Leader> leaders) throws JSONException {
    JSONArray userList = new JSONArray();
    JSONObject finalObj = new JSONObject();

    for (Leader leader : leaders) {
      List<PRInfo> prs = leader.getPullRequests();
      JSONObject userInfo = new JSONObject();
      userInfo.put("slug", leader.getSlug());
      userInfo.put("displayName", leader.getDisplayName());
      JSONArray prArray = new JSONArray();
      for (PRInfo pr : prs) {
        JSONObject prInfo = new JSONObject();
        prInfo.put("id", pr.getId());
        prInfo.put("date", pr.getDate());
        prInfo.put("role", pr.getRole().toString());
        prArray.put(prInfo);
      }
      userInfo.put("pullRequests", prArray);
      userList.put(userInfo);
    }
    finalObj.put("users", userList);
    return finalObj;
  }
  public void updatePrInList(Leader oldLeader, Leader newLeader) {
    boolean inList = false;
    PRInfo newPr = newLeader.getPullRequests().get(0);
    List<PRInfo> oldPRList = oldLeader.getPullRequests();
    Scoring scoring = oldLeader.getScoring();

    for (int i = 0; i < oldPRList.size(); i++) {
      PRInfo oldPr = oldPRList.get(i);
      if (oldPr.getId() == newPr.getId()) {
        if (scoring.getPositionToScore(newPr.getRole().getPosition())
            >= scoring.getPositionToScore(oldPr.getRole().getPosition())) {
          oldPr.setDate(newPr.getDate());
          oldPr.setRole(newPr.getRole());
        } else if (scoring.getPositionToScore(newPr.getRole().getPosition())
            < scoring.getPositionToScore(oldPr.getRole().getPosition())) {
          oldPr.setDate(newPr.getDate());
        } else if (newPr.getRole() == Role.NULL) {
          oldPRList.remove(i);
        }
        inList = true;
        break;
      }
    }

    if ((!inList || oldPRList.isEmpty()) && (newPr.getRole() != Role.NULL)) {
      oldPRList.add(newPr);
    }
  }