Package com.atlassian.jira.rest.client.api.domain

Examples of com.atlassian.jira.rest.client.api.domain.Issue


      }
    });
  }

  private void testTransitionImpl(Comment comment) {
    final Issue issue = client.getIssueClient().getIssue("TST-1").claim();
    final Iterable<Transition> transitions = client.getIssueClient().getTransitions(issue).claim();
    Transition transitionFound = TestUtil.getTransitionByName(transitions, "Estimate");
    DateTime now = new DateTime();
    client.getIssueClient().transition(issue, new TransitionInput(transitionFound.getId(), comment)).claim();

    final Issue changedIssue = client.getIssueClient().getIssue("TST-1").claim();
    final Comment lastComment = Iterables.getLast(changedIssue.getComments());
    assertEquals(comment.getBody(), lastComment.getBody());
    assertEquals(IntegrationTestUtil.USER_ADMIN, lastComment.getAuthor());
    assertEquals(IntegrationTestUtil.USER_ADMIN, lastComment.getUpdateAuthor());
    assertEquals(lastComment.getCreationDate(), lastComment.getUpdateDate());
    assertTrue(lastComment.getCreationDate().isAfter(now) || lastComment.getCreationDate().isEqual(now));
View Full Code Here


    assertEquals(comment.getVisibility(), lastComment.getVisibility());
  }

  @Test
  public void testVoteUnvote() {
    final Issue issue1 = client.getIssueClient().getIssue("TST-1").claim();
    assertFalse(issue1.getVotes().hasVoted());
    assertEquals(1, issue1.getVotes().getVotes()); // the other user has voted
    final String expectedMessage = isJira5xOrNewer() // JIRA 5.0 comes without Polish translation OOB
        ? "You cannot vote for an issue you have reported."
        : "Nie mo\u017cesz g\u0142osowa\u0107 na zadanie kt\u00f3re utworzy\u0142e\u015b.";

    // I hope that such Polish special characters (for better testing local specific behaviour of REST
    assertErrorCode(Response.Status.NOT_FOUND, expectedMessage, new Runnable() {
      @Override
      public void run() {
        client.getIssueClient().vote(issue1.getVotesUri()).claim();
      }
    });


    final String issueKey = "TST-7";
    Issue issue = client.getIssueClient().getIssue(issueKey).claim();
    assertFalse(issue.getVotes().hasVoted());
    assertEquals(0, issue.getVotes().getVotes());

    client.getIssueClient().vote(issue.getVotesUri()).claim();
    issue = client.getIssueClient().getIssue(issueKey).claim();
    assertTrue(issue.getVotes().hasVoted());
    assertEquals(1, issue.getVotes().getVotes());

    client.getIssueClient().unvote(issue.getVotesUri()).claim();
    issue = client.getIssueClient().getIssue(issueKey).claim();
    assertFalse(issue.getVotes().hasVoted());
    assertEquals(0, issue.getVotes().getVotes());

    setUser2();
    issue = client.getIssueClient().getIssue(issueKey).claim();
    assertFalse(issue.getVotes().hasVoted());
    assertEquals(0, issue.getVotes().getVotes());
    final Issue finalIssue = issue;
    assertErrorCode(Response.Status.NOT_FOUND, "Cannot remove a vote for an issue that the user has not already voted for.",
        new Runnable() {
          @Override
          public void run() {
            client.getIssueClient().unvote(finalIssue.getVotesUri()).claim();
          }
        });


    issue = client.getIssueClient().getIssue(issueKey).claim();
View Full Code Here

  }

  @Test
  public void testWatchUnwatch() {
    final IssueRestClient issueClient = client.getIssueClient();
    final Issue issue1 = issueClient.getIssue("TST-1").claim();

    Assert.assertThat(issueClient.getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), not(hasItem(IntegrationTestUtil.USER_ADMIN)));

    issueClient.watch(issue1.getWatchers().getSelf()).claim();
    Assert.assertThat(issueClient.getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), hasItem(IntegrationTestUtil.USER_ADMIN));

    issueClient.unwatch(issue1.getWatchers().getSelf()).claim();
    Assert.assertThat(issueClient.getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), not(hasItem(IntegrationTestUtil.USER_ADMIN)));

    Assert.assertThat(issueClient.getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), hasItem(IntegrationTestUtil.USER1));
    issueClient.removeWatcher(issue1.getWatchers().getSelf(), IntegrationTestUtil.USER1.getName()).claim();
    Assert.assertThat(issueClient.getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), not(hasItem(IntegrationTestUtil.USER1)));
    issueClient.addWatcher(issue1.getWatchers().getSelf(), IntegrationTestUtil.USER1.getName()).claim();
    Assert.assertThat(issueClient.getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), hasItem(IntegrationTestUtil.USER1));
  }
View Full Code Here

  }

  @Test
  public void testRemoveWatcherUnauthorized() {
    final IssueRestClient issueClient = client.getIssueClient();
    final Issue issue1 = issueClient.getIssue("TST-1").claim();
    issueClient.watch(issue1.getWatchers().getSelf()).claim();

    setUser1();
    final IssueRestClient issueClient2 = client.getIssueClient();
    assertErrorCode(Response.Status.UNAUTHORIZED,
        "User 'wseliga' is not allowed to remove watchers from issue 'TST-1'", new Runnable() {
      @Override
      public void run() {
        issueClient2.removeWatcher(issue1.getWatchers().getSelf(), ADMIN_USERNAME).claim();
      }
    });
  }
View Full Code Here

  @Test
  public void testWatchAlreadyWatched() {
    setUser1();
    final IssueRestClient issueClient = client.getIssueClient();
    final Issue issue = issueClient.getIssue("TST-1").claim();
    Assert.assertThat(client.getIssueClient().getWatchers(issue.getWatchers().getSelf()).claim()
        .getUsers(), hasItem(IntegrationTestUtil.USER1));
    // JIRA allows to watch already watched issue by you - such action effectively has no effect
    issueClient.watch(issue.getWatchers().getSelf()).claim();
    Assert.assertThat(client.getIssueClient().getWatchers(issue.getWatchers().getSelf()).claim()
        .getUsers(), hasItem(IntegrationTestUtil.USER1));
  }
View Full Code Here

  public void testJqlSearchWithStartAt() {
    final int maxResults = 3;

    // returns: 0,1,2
    final SearchResult searchResultFrom0 = client.getSearchClient().searchJql(null, maxResults, 0, null).claim();
    final Issue secondIssueFromFirstSearch = Iterables.get(searchResultFrom0.getIssues(), 1);

    // returns: 1,2,3
    final SearchResult searchResultFrom1 = client.getSearchClient().searchJql(null, maxResults, 1, null).claim();
    final Issue firstIssueFromSecondSearch = Iterables.get(searchResultFrom1.getIssues(), 0);

    assertEquals(secondIssueFromFirstSearch, firstIssueFromSecondSearch);
  }
View Full Code Here

    jqlSearchShouldReturnIssueWithDetails("rest/api/2/project/10000");
  }

  private void jqlSearchShouldReturnIssueWithDetails(String projectSelf) {
    final SearchResult searchResult = client.getSearchClient().searchJql("reporter=wseliga").claim();
    final Issue issue = Iterables.getOnlyElement(searchResult.getIssues());

    assertEquals("TST-7", issue.getKey());
    assertEquals(Long.valueOf(10040), issue.getId());
    assertEquals(resolveURI("rest/api/latest/issue/10040"), issue.getSelf());
    assertEquals("A task where someone will vote", issue.getSummary());
    assertNull(issue.getDescription()); // by default search doesn't retrieve description
    assertEquals(new BasicPriority(resolveURI("rest/api/2/priority/3"), 3L, "Major"), issue.getPriority());
    assertThat(issue.getStatus(), allOf(
        hasProperty("self", is(resolveURI("rest/api/2/status/1"))),
        hasProperty("id", is(1L)),
        hasProperty("name", is("Open")),
        hasProperty("description", is("The issue is open and ready for the assignee to start work on it.")),
        anyOf(
            hasProperty("iconUrl", is(resolveURI("images/icons/statuses/open.png"))), // Jira >= 5.2
            hasProperty("iconUrl", is(resolveURI("images/icons/status_open.gif"))) // Jira < 5.2
        )));
    assertEmptyIterable(issue.getComments())// not expanded by default
    assertEmptyIterable(issue.getComponents());
    assertEmptyIterable(issue.getWorklogs());
    assertEmptyIterable(issue.getSubtasks());
    assertEmptyIterable(issue.getIssueLinks());
    assertEmptyIterable(issue.getFixVersions());
    assertEmptyIterable(issue.getAffectedVersions());
    assertEmptyIterable(issue.getLabels());
    assertNull(issue.getDueDate());
    assertNull(issue.getTimeTracking());
    assertNull(issue.getResolution());
    assertNull(issue.getChangelog());
    assertNull(issue.getAttachments());
    // JIRA does not store timezone information in its dump file, so no timezone here
    assertEquals(toDateTime("2010-09-22T18:06:32.000"), issue.getUpdateDate());
    assertEquals(toDateTime("2010-09-22T18:06:32.000"), issue.getCreationDate());
    assertEquals(IntegrationTestUtil.USER1_FULL, issue.getReporter());
    assertEquals(IntegrationTestUtil.USER_ADMIN_FULL, issue.getAssignee());
    assertEquals(new BasicProject(resolveURI(projectSelf), "TST", 10000L, "Test Project"), issue.getProject());
    assertEquals(new BasicVotes(resolveURI("rest/api/2/issue/TST-7/votes"), 0, false), issue.getVotes());
    assertEquals(new BasicWatchers(resolveURI("rest/api/2/issue/TST-7/watchers"), false, 0), issue.getWatchers());
    assertThat(issue.getIssueType(), notNullValue());
    assertThat(issue.getIssueType().getSelf(), is(resolveURI("rest/api/2/issuetype/3")));
    assertThat(issue.getIssueType().getId(), is(3L));
    assertThat(issue.getIssueType().getName(), is("Task"));
    assertThat(issue.getIssueType().isSubtask(), is(false));
    assertThat(issue.getIssueType().getDescription(), is("A task that needs to be done."));
    assertThat(issue.getIssueType().getIconUri(), anyOf(
        is(resolveURI("images/icons/issuetypes/task.png")),
        is(resolveURI("images/icons/task.gif"))
    ));
  }
View Full Code Here

  }

  private void jqlSearchWithAllFieldsImpl(String jql) {
    final ImmutableSet<String> fields = ImmutableSet.of("*all");
    final SearchResult searchResult = client.getSearchClient().searchJql(jql, null, null, fields).claim();
    final Issue issue = Iterables.getOnlyElement(searchResult.getIssues());

    assertEquals("TST-2", issue.getKey());
    assertEquals("Testing attachem2", issue.getSummary());
    assertEquals(new TimeTracking(0, 0, 145), issue.getTimeTracking());
    assertThat(issue.getComponents(), NamedEntityMatchers.entitiesWithNames("Component A", "Component B"));

    // comments
    final Iterable<Comment> comments = issue.getComments();
    assertEquals(3, Iterables.size(comments));
    assertEquals("a comment viewable only by jira-users", Iterables.getLast(comments).getBody());

    // worklogs
    final Iterable<Worklog> worklogs = issue.getWorklogs();
    assertThat(worklogs, AddressableEntityMatchers.entitiesWithSelf(
        resolveURI("rest/api/2/issue/10010/worklog/10010"),
        resolveURI("rest/api/2/issue/10010/worklog/10011"),
        resolveURI("rest/api/2/issue/10010/worklog/10012"),
        resolveURI("rest/api/2/issue/10010/worklog/10020"),
        resolveURI("rest/api/2/issue/10010/worklog/10021")
    ));

    final Worklog actualWorklog = Iterables.getLast(worklogs);
    final Worklog expectedWorklog = new Worklog(resolveURI("rest/api/2/issue/10010/worklog/10021"),
        resolveURI("rest/api/latest/issue/10010"), IntegrationTestUtil.USER_ADMIN, IntegrationTestUtil.USER_ADMIN,
        "Another work for 7 min", toDateTime("2010-08-27T15:00:02.104"), toDateTime("2010-08-27T15:00:02.104"),
        toDateTime("2010-08-27T14:59:00.000"), 7, null);
    assertEquals(expectedWorklog, actualWorklog);

    // issue links
    assertThat(issue.getIssueLinks(), IsIterableContainingInOrder.contains(
        new IssueLink("TST-1", resolveURI("rest/api/2/issue/10000"), new IssueLinkType("Duplicate", "duplicates", IssueLinkType.Direction.OUTBOUND)),
        new IssueLink("TST-1", resolveURI("rest/api/2/issue/10000"), new IssueLinkType("Duplicate", "is duplicated by", IssueLinkType.Direction.INBOUND))
    ));

    // fix versions
    final Version actualFixVersion = Iterables.getOnlyElement(issue.getFixVersions());
    final Version expectedFixVersion = new Version(resolveURI("rest/api/2/version/10000"), 10000L, "1.1", "Some version", false, false, toDateTime("2010-08-25T00:00:00.000"));
    assertEquals(expectedFixVersion, actualFixVersion);

    // affected versions
    assertThat(issue.getAffectedVersions(), IsIterableContainingInOrder.contains(
        new Version(resolveURI("rest/api/2/version/10001"), 10001L, "1", "initial version", false, false, null),
        new Version(resolveURI("rest/api/2/version/10000"), 10000L, "1.1", "Some version", false, false, toDateTime("2010-08-25T00:00:00.000"))
    ));

    // dates
    assertNull(issue.getDueDate());
    assertEquals(toDateTime("2010-08-30T10:49:33.000"), issue.getUpdateDate());
    assertEquals(toDateTime("2010-07-26T13:29:18.000"), issue.getCreationDate());

    // attachments
    final Iterable<String> attachmentsNames = EntityHelper.toFileNamesList(issue.getAttachments());
    assertThat(attachmentsNames, containsInAnyOrder("10000_thumb_snipe.jpg", "Admal pompa ciepÅ‚a.pdf",
        "apache-tomcat-5.5.30.zip", "jira_logo.gif", "snipe.png", "transparent-png.png"));
  }
View Full Code Here

  }

  @Test
  public void jqlSearchShouldReturnIssueWithLabelsAndDueDate() throws Exception {
    final SearchResult searchResult = client.getSearchClient().searchJql("key=TST-1").claim();
    final Issue issue = Iterables.getOnlyElement(searchResult.getIssues());
    assertEquals("TST-1", issue.getKey());
    assertThat(issue.getLabels(), containsInAnyOrder("a", "bcds"));
    assertEquals(toDateTime("2010-07-05T00:00:00.000"), issue.getDueDate());
  }
View Full Code Here

  @Test
  public void jqlSearchWithMinimalFieldSetShouldReturnParseableIssues() throws Exception {
    final SearchRestClient searchClient = client.getSearchClient();
    final SearchResult searchResult = searchClient.searchJql("key=TST-1", null, null, REQUIRED_ISSUE_FIELDS).claim();
    final Issue issue = Iterables.getOnlyElement(searchResult.getIssues());
    assertEquals("TST-1", issue.getKey());
    assertEquals("My sample test", issue.getSummary());
    assertEquals("Bug", issue.getIssueType().getName());
    assertEquals(toDateTime("2010-07-23T12:16:56.000"), issue.getCreationDate());
    assertEquals(toDateTime("2010-08-17T16:36:29.000"), issue.getUpdateDate());
    assertEquals("Test Project", issue.getProject().getName());
    assertEquals(Long.valueOf(10000), issue.getId());
    assertEquals("Open", issue.getStatus().getName());

    // this issue has labels, but they were not returned by JIRA REST API
    assertEmptyIterable(issue.getLabels());
    final Issue fullIssue = client.getIssueClient().getIssue(issue.getKey()).claim();
    assertThat(fullIssue.getLabels(), containsInAnyOrder("a", "bcds"));
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.api.domain.Issue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.