Exemplo n.º 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());
  }
Exemplo n.º 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());
  }
Exemplo n.º 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());
  }
Exemplo n.º 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());
  }
Exemplo n.º 5
0
 /**
  * Tests that {@code editIssueState} returns Optional.empty() if the model for the issue given in
  * the argument can't be found
  */
 @Test
 public void editIssueState_issueNotFound() {
   Model model = new Model("testrepo");
   assertEquals(Optional.empty(), model.editIssueState(1, true));
   assertEquals(Optional.empty(), model.editIssueState(1, false));
 }
Exemplo n.º 6
0
 /**
  * Tests that replaceIssueAssigneeOnServer returns Optional.empty() if the model for the issue
  * given in the argument can't be found
  */
 @Test
 public void replaceIssueAssignee_issueNotFound() {
   Model model = new Model("testrepo");
   assertEquals(Optional.empty(), model.replaceIssueAssignee(1, Optional.of("")));
 }
Exemplo n.º 7
0
 /**
  * Tests that replaceIssueLabels returns Optional.empty() if the model for the issue given in the
  * argument can't be found
  */
 @Test
 public void replaceIssueLabels_issueNotFound() {
   Model model = new Model("testrepo");
   assertEquals(Optional.empty(), model.replaceIssueLabels(1, new ArrayList<>()));
 }
Exemplo n.º 8
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());
  }