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

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


    assertTrue(Iterables.contains(transitionsAfterTransition, stopProgressTransition));
  }

  private void assertThatIssueNotExists(String issueKey) {
    try {
      final Issue issue = client.getIssueClient().getIssue(issueKey).claim();
      fail("It looks that issue exists, and it should not be here! issue = " + issue);
    } catch (RestClientException ex) {
      assertThat(ex, rceWithSingleError(404, "Issue Does Not Exist"));
    }
  }
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

  }

  @Test
  public void jqlSearchShouldReturnIssueWithDetails() throws InvocationTargetException, IllegalAccessException {
    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());
    assertEquals(new BasicStatus(resolveURI("rest/api/2/status/1"), "Open"), issue.getStatus());
    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("rest/api/2/project/TST"), "TST", "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());
    assertEquals(new BasicIssueType(resolveURI("rest/api/2/issuetype/3"), 3L, "Task", false), issue.getIssueType());
  }
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

    // create
    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInputBuilder.build()).claim();
    assertNotNull(basicCreatedIssue.getKey());

    // get issue and check if everything was set as we expected
    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
    assertNotNull(createdIssue);

    assertEquals(basicCreatedIssue.getKey(), createdIssue.getKey());
    assertEquals(project.getKey(), createdIssue.getProject().getKey());
    assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
    assertEquals(summary, createdIssue.getSummary());
    assertEquals(description, createdIssue.getDescription());

    final User actualAssignee = createdIssue.getAssignee();
    assertNotNull(actualAssignee);
    assertEquals(assignee.getSelf(), actualAssignee.getSelf());
    // TODO we need some users for integration tests!
    assertEquals(actualAssignee.getEmailAddress(), "wojciech.seliga@spartez.com");

    final Iterable<String> actualAffectedVersionsNames = EntityHelper.toNamesList(createdIssue.getAffectedVersions());
    assertThat(affectedVersionsNames, containsInAnyOrder(toArray(actualAffectedVersionsNames, String.class)));

    final Iterable<String> actualFixVersionsNames = EntityHelper.toNamesList(createdIssue.getFixVersions());
    assertThat(fixVersionsNames, containsInAnyOrder(toArray(actualFixVersionsNames, String.class)));

    assertTrue(createdIssue.getComponents().iterator().hasNext());
    assertEquals(component.getId(), createdIssue.getComponents().iterator().next().getId());

    // strip time from dueDate
    final DateTime expectedDueDate = JsonParseUtil.parseDate(JsonParseUtil.formatDate(dueDate));
    assertEquals(expectedDueDate, createdIssue.getDueDate());

    final BasicPriority actualPriority = createdIssue.getPriority();
    assertNotNull(actualPriority);
    assertEquals(priority.getId(), actualPriority.getId());

    // check value of MultiUserSelect field
    final Object multiUserValue = createdIssue.getField(multiUserCustomFieldId).getValue();
    // ideally this should be Iterable<User>, but for now it's just an JSONArray...
    assertThat(multiUserValue, Matchers.instanceOf(JSONArray.class));
    final JSONArray multiUserArray = (JSONArray) multiUserValue;
    final List<String> actualMultiUserNames = Lists.newArrayListWithCapacity(multiUserArray.length());
    for (int i = 0; i<multiUserArray.length(); i++) {
View Full Code Here

    // create
    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInputBuilder.build()).claim();
    assertNotNull(basicCreatedIssue.getKey());

    // get issue and check if everything was set as we expected
    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
    assertNotNull(createdIssue);

    assertEquals(basicCreatedIssue.getKey(), createdIssue.getKey());
    assertEquals(project.getKey(), createdIssue.getProject().getKey());
    assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
    assertEquals(summary, createdIssue.getSummary());
    assertEquals(description, createdIssue.getDescription());

    final BasicUser actualAssignee = createdIssue.getAssignee();
    assertNotNull(actualAssignee);
    assertEquals(assignee.getSelf(), actualAssignee.getSelf());

    final Iterable<String> actualAffectedVersionsNames = EntityHelper.toNamesList(createdIssue.getAffectedVersions());
    assertThat(affectedVersionsNames, containsInAnyOrder(toArray(actualAffectedVersionsNames, String.class)));

    final Iterable<String> actualFixVersionsNames = EntityHelper.toNamesList(createdIssue.getFixVersions());
    assertThat(fixVersionsNames, containsInAnyOrder(toArray(actualFixVersionsNames, String.class)));

    assertTrue(createdIssue.getComponents().iterator().hasNext());
    assertEquals(component.getId(), createdIssue.getComponents().iterator().next().getId());

    // strip time from dueDate
    final DateTime expectedDueDate = JsonParseUtil.parseDate(JsonParseUtil.formatDate(dueDate));
    assertEquals(expectedDueDate, createdIssue.getDueDate());

    final BasicPriority actualPriority = createdIssue.getPriority();
    assertNotNull(actualPriority);
    assertEquals(priority.getId(), actualPriority.getId());
  }
View Full Code Here

      }
    }));

    assertEquals(summaries, createdSummariesOrder);

    final Issue parentIssue = issueClient.getIssue("TST-1").claim();
    final Set<String> subtaskKeys = ImmutableSet.copyOf(Iterables.transform(parentIssue
        .getSubtasks(), new Function<Subtask, String>() {
      @Override
      public String apply(final Subtask subtask) {
        return subtask.getIssueKey();
      }
    }));

    for (final BasicIssue basicIssue : createdIssues.getIssues()) {

      // get issue and check if everything was set as we expected
      final Issue createdIssue = issueClient.getIssue(basicIssue.getKey()).claim();
      assertNotNull(createdIssue);

      assertEquals(basicIssue.getKey(), createdIssue.getKey());
      assertEquals(project.getKey(), createdIssue.getProject().getKey());
      assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
      assertTrue(summaries.contains(createdIssue.getSummary()));
      assertEquals( description, createdIssue.getDescription());

      final BasicUser actualAssignee = createdIssue.getAssignee();
      assertNotNull(actualAssignee);
      assertEquals(assignee.getSelf(), actualAssignee.getSelf());

      assertTrue(subtaskKeys.contains(createdIssue.getKey()));
    }
  }
View Full Code Here

      }
    }));

    assertEquals(expectedSummariesOrder, createdSummariesOrder);

    final Issue parentIssue = issueClient.getIssue("TST-1").claim();
    final Set<String> subtaskKeys = ImmutableSet.copyOf(Iterables.transform(parentIssue
        .getSubtasks(), new Function<Subtask, String>() {
      @Override
      public String apply(Subtask subtask) {
        return subtask.getIssueKey();
      }
    }));

    for (final BasicIssue basicIssue : createdIssues.getIssues()) {

      // get issue and check if everything was set as we expected
      final Issue createdIssue = issueClient.getIssue(basicIssue.getKey()).claim();
      assertNotNull(createdIssue);

      assertEquals(basicIssue.getKey(), createdIssue.getKey());
      assertEquals(project.getKey(), createdIssue.getProject().getKey());
      assertEquals(issueType.getId(), createdIssue.getIssueType().getId());
      assertEquals( description, createdIssue.getDescription());

      final BasicUser actualAssignee = createdIssue.getAssignee();
      assertNotNull(actualAssignee);
      assertEquals(assignee.getSelf(), actualAssignee.getSelf());

      assertTrue(summaries.contains(createdIssue.getSummary()));
      assertFalse(summariesWithError.contains(createdIssue.getSummary()));

      assertTrue(subtaskKeys.contains(createdIssue.getKey()));
    }
  }
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.