Example #1
0
  @Test
  public void operations() {

    // Issues

    try {
      modelUpdated.getIssueById(0);
    } catch (AssertionError ignored) {
    }
    try {
      modelUpdated.getIssueById(-1);
    } catch (AssertionError ignored) {
    }

    assertEquals(
        Optional.<TurboIssue>empty(),
        modelUpdated.getIssueById(DummyRepoState.NO_OF_DUMMY_ISSUES + 1));
    assertEquals("Issue 10", modelUpdated.getIssueById(10).get().getTitle());

    // Labels

    try {
      modelUpdated.getLabelByActualName(null);
    } catch (AssertionError ignored) {
    }
    try {
      modelUpdated.getLabelByActualName("");
    } catch (AssertionError ignored) {
    }

    assertEquals(
        Optional.<TurboLabel>empty(),
        modelUpdated.getLabelByActualName("Label " + (DummyRepoState.NO_OF_DUMMY_ISSUES + 1)));
    assertEquals("Label 10", modelUpdated.getLabelByActualName("Label 10").get().getFullName());

    // Milestones

    try {
      modelUpdated.getMilestoneById(-1);
    } catch (AssertionError ignored) {
    }
    try {
      modelUpdated.getMilestoneById(0);
    } catch (AssertionError ignored) {
    }

    try {
      modelUpdated.getMilestoneByTitle(null);
    } catch (AssertionError ignored) {
    }
    try {
      modelUpdated.getMilestoneByTitle("");
    } catch (AssertionError ignored) {
    }

    assertEquals(
        Optional.<TurboMilestone>empty(),
        modelUpdated.getMilestoneById(DummyRepoState.NO_OF_DUMMY_ISSUES + 1));
    assertEquals("Milestone 10", modelUpdated.getMilestoneById(10).get().getTitle());

    assertEquals(
        Optional.<TurboMilestone>empty(),
        modelUpdated.getMilestoneByTitle("Milestone " + (DummyRepoState.NO_OF_DUMMY_ISSUES + 1)));
    assertEquals("Milestone 10", modelUpdated.getMilestoneByTitle("Milestone 10").get().getTitle());

    // Users

    try {
      modelUpdated.getUserByLogin(null);
    } catch (AssertionError ignored) {
    }
    try {
      modelUpdated.getUserByLogin("");
    } catch (AssertionError ignored) {
    }

    assertEquals(
        Optional.<TurboUser>empty(),
        modelUpdated.getUserByLogin("User " + (DummyRepoState.NO_OF_DUMMY_ISSUES + 1)));
    assertEquals("User 10", modelUpdated.getUserByLogin("User 10").get().getLoginName());
  }
Example #2
0
  @Test
  public void getters() {
    // ID
    assertEquals(REPO, modelUpdated.getRepoId());
    assertEquals(modelUpdated.getRepoId(), modelUpdated.getRepoId());

    // Signature
    assertEquals(true, modelEmptySig.getUpdateSignature().isEmpty());
    assertEquals(modelEmptySig.getUpdateSignature(), UpdateSignature.EMPTY);
    assertEquals(modelEmptySig.getUpdateSignature(), modelEmptySig2.getUpdateSignature());

    // Resources
    // Issues
    ArrayList<Integer> issueIds = new ArrayList<>();
    for (int i = 1; i <= DummyRepoState.NO_OF_DUMMY_ISSUES; i++) {
      issueIds.add(i);
    }
    Collections.sort(issueIds); // 1, 2..10
    int issueCount = 1;
    for (TurboIssue issue : modelUpdated.getIssues()) {
      assertEquals(issueCount, modelUpdated.getIssueById(issueCount).get().getId());
      assertEquals(issueIds.get(issueCount - 1).intValue(), issue.getId());
      issueCount++;
    }

    // Labels
    ArrayList<String> labelNames = new ArrayList<>();
    for (int i = 1; i <= DummyRepoState.NO_OF_DUMMY_ISSUES; i++) {
      labelNames.add("Label " + i);
    }
    Collections.sort(labelNames); // Label 1, Label 10..12, Label 2..9
    int labelCount = 1;
    for (TurboLabel label : modelUpdated.getLabels()) {
      if (label.getFullName().startsWith("Label")) {
        assertEquals(labelNames.get(labelCount - 1), label.getFullName());
        assertEquals(
            "Label " + labelCount,
            modelUpdated.getLabelByActualName("Label " + labelCount).get().getFullName());
        labelCount++;
      }
    }

    // Milestones
    ArrayList<Integer> milestoneIds = new ArrayList<>();
    for (int i = 1; i <= DummyRepoState.NO_OF_DUMMY_ISSUES; i++) {
      milestoneIds.add(i);
    }
    Collections.sort(milestoneIds); // 1, 2..10
    int milestoneCount = 1;
    for (TurboMilestone milestone : modelUpdated.getMilestones()) {
      assertEquals(milestoneCount, milestone.getId());
      assertEquals(
          milestoneIds.get(milestoneCount - 1).intValue(),
          modelUpdated.getMilestoneById(milestoneCount).get().getId());
      assertEquals(
          "Milestone " + milestoneCount,
          modelUpdated.getMilestoneByTitle("Milestone " + milestoneCount).get().getTitle());
      milestoneCount++;
    }

    // Users
    ArrayList<String> userLogins = new ArrayList<>();
    for (int i = 1; i <= DummyRepoState.NO_OF_DUMMY_ISSUES; i++) {
      userLogins.add("User " + i);
    }
    Collections.sort(userLogins); // User 1, User 10, User 2..9
    int userCount = 1;
    for (TurboUser user : modelUpdated.getUsers()) {
      assertEquals(userLogins.get(userCount - 1), user.getLoginName());
      assertEquals(
          "User " + userCount,
          modelUpdated.getUserByLogin("User " + userCount).get().getLoginName());
      userCount++;
    }
  }