Example #1
0
  /**
   * Tests that {@code editIssueState} finds issue with the right id and successfully modify the
   * issue's labels
   */
  @Test
  public void editIssueState_successful() {
    String repoId = "testowner/testrepo";
    Optional<TurboIssue> result;

    TurboIssue issue1 = LogicTests.createOpenIssue();
    TurboIssue issue2 = LogicTests.createClosedIssue();
    List<TurboIssue> issues = Arrays.asList(issue2, issue1);
    Model model =
        new Model(
            repoId,
            issues,
            new ArrayList<TurboLabel>(),
            new ArrayList<TurboMilestone>(),
            new ArrayList<TurboUser>());

    result = model.editIssueState(issue1.getId(), false);
    assertEquals(issue1.getId(), result.get().getId());
    assertEquals(false, result.get().isOpen());

    result = model.editIssueState(issue2.getId(), true);
    assertEquals(issue2.getId(), result.get().getId());
    assertEquals(true, result.get().isOpen());

    result = model.editIssueState(issue2.getId(), true);
    assertEquals(issue2.getId(), result.get().getId());
    assertEquals(true, result.get().isOpen());
  }
Example #2
0
  /**
   * Tests that replaceIssueAssigneeOnServer finds issue with the right id and successfully modify
   * the issue's assignee
   */
  @Test
  public void replaceIssueAssignee_successful() {
    String repoId = "testowner/testrepo";
    String originalAssignee = "user1";
    String newAssignee = "user2";

    TurboIssue issue1 = LogicTests.createIssueWithAssignee(1, originalAssignee);
    TurboIssue issue2 = LogicTests.createIssueWithAssignee(2, originalAssignee);
    TurboIssue issue3 = LogicTests.createIssueWithAssignee(3, originalAssignee);
    List<TurboIssue> issues = Arrays.asList(issue3, issue2, issue1);

    Model model =
        new Model(repoId, issues, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
    Optional<TurboIssue> result =
        model.replaceIssueAssignee(issue1.getId(), Optional.of(newAssignee));
    assertEquals(1, result.get().getId());
    assertEquals(newAssignee, result.get().getAssignee().get());
  }
Example #3
0
  /**
   * Tests that replaceIssueLabelsOnServer finds issue with the right id and successfully modify the
   * issue's labels
   */
  @Test
  public void replaceIssueLabels_successful() {
    String repoId = "testowner/testrepo";
    List<String> originalLabels = Arrays.asList("label1", "label2");
    List<String> newLabels = Arrays.asList("label3", "label4");

    TurboIssue issue1 = LogicTests.createIssueWithLabels(1, originalLabels);
    TurboIssue issue2 = LogicTests.createIssueWithLabels(2, originalLabels);
    TurboIssue issue3 = LogicTests.createIssueWithLabels(3, originalLabels);
    List<TurboIssue> issues = Arrays.asList(issue3, issue2, issue1);

    Model model =
        new Model(
            repoId,
            issues,
            new ArrayList<TurboLabel>(),
            new ArrayList<TurboMilestone>(),
            new ArrayList<TurboUser>());
    Optional<TurboIssue> result = model.replaceIssueLabels(issue1.getId(), newLabels);
    assertEquals(1, result.get().getId());
    assertEquals(newLabels, result.get().getLabels());
  }
Example #4
0
  /**
   * Tests that replaceIssueMilestone finds issue with the right id and successfully modify the
   * issue's milestone
   */
  @Test
  public void replaceIssueMilestone_successful() {
    Optional<Integer> milestoneIdReplacement = Optional.of(1);
    String repoId = "testowner/testrepo";

    TurboIssue issue1 = LogicTests.createIssueWithMilestone(1, Optional.of(0));
    TurboIssue issue2 = LogicTests.createIssueWithMilestone(2, Optional.of(1));
    TurboIssue issue3 = LogicTests.createIssueWithMilestone(3, Optional.of(1));
    List<TurboIssue> issues = Arrays.asList(issue3, issue2, issue1);

    Model model =
        new Model(
            repoId,
            issues,
            new ArrayList<TurboLabel>(),
            new ArrayList<TurboMilestone>(),
            new ArrayList<TurboUser>());
    Optional<TurboIssue> result =
        model.replaceIssueMilestone(issue1.getId(), milestoneIdReplacement);
    assertEquals(1, result.get().getId());
    assertTrue(result.get().getMilestone().isPresent());
    assertEquals(milestoneIdReplacement, result.get().getMilestone());
  }