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

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


        Set<String> labels = null;
        JSONObject rawObject = null;

        BasicIssue basicIssue = mockSearchRestClient.getBasicIssue(issueKey);
        Collection<Comment> comments = mockSearchRestClient.getCommentsForIssue(basicIssue.getId());
        Issue issue = new Issue(summary, self, basicIssue.getKey(), basicIssue.getId(), project, issueType, status,
                description, priority, resolution, attachments, reporter, assignee, creationDate, updateDate,
                dueDate, affectedVersions, fixVersions, components, timeTracking, fields, comments,
                transitionsUri, issueLinks,
                votes, worklogs, watchers, expandos, subtasks, changelog, labels, rawObject);
        return issue;
View Full Code Here


    // In the end, we want *new* comments oldest to newest.
    private Stack<Comment> getComments() {
        Stack<Comment> newComments = new Stack<Comment>();
        List<BasicIssue> issues = getIssues();
        for (BasicIssue issue : issues) {
            Issue fullIssue = client().getIssueClient().getIssue(issue.getKey(), null);
            for (Comment comment : fullIssue.getComments()) {
                if (!commentIds.contains(comment.getId())) {
                    newComments.push(comment);
                    commentIds.add(comment.getId());
                }
            }
View Full Code Here

    try {
      JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
      JiraRestClient restClient = factory
          .createWithBasicHttpAuthentication(new URI(annotation.server()), getUserName(), getPassword());
      try {
        Issue issue = restClient.getIssueClient().getIssue(annotation.issue()).get();
        if (!issue.getStatus().getName().equalsIgnoreCase("CLOSED")) {
          return Status.OPEN;
        } else {
          return Status.CLOSED;
        }
      } catch (ExecutionException e) {
View Full Code Here

   
    final WorklogInputBuilder worklogInputBuilder = createDefaulWorklogInputBuilder();
    final IssueRestClient issueClient = client.getIssueClient();

    // get issue
    final Issue initialIssue = issueClient.getIssue(issueKey, pm);

    // # First change - test auto
    final WorklogInput worklogInput = worklogInputBuilder
        .setIssueUri(initialIssue.getSelf())
        .setMinutesSpent(2)
        .build();
    issueClient.addWorklog(initialIssue.getWorklogUri(), worklogInput, pm);

    // check if estimate has changed
    final Issue issueAfterFirstChange = issueClient.getIssue(issueKey, pm);
    final Integer actualTimeSpentAfterChange = getTimeSpentMinutesNotNull(issueAfterFirstChange.getTimeTracking());
    final Integer expectedTimeSpentAfterChange = getTimeSpentMinutesNotNull(initialIssue.getTimeTracking()) + worklogInput.getMinutesSpent();
    assertEquals(expectedTimeSpentAfterChange, actualTimeSpentAfterChange);

    final int actualRemainingEstimate = getRemainingEstimateMinutesNotNull(issueAfterFirstChange.getTimeTracking());
    final int expectedRemaningEstimate = getRemainingEstimateMinutesNotNull(initialIssue.getTimeTracking()) - worklogInput.getMinutesSpent();
    assertEquals(expectedRemaningEstimate, actualRemainingEstimate);

    // # Second change - test new; also we want to be sure that logged time are added, and not set to given value
    final Integer newEstimateValue = 15;
    final WorklogInput worklogInput2 = worklogInputBuilder
        .setIssueUri(initialIssue.getSelf())
        .setMinutesSpent(2)
        .setAdjustEstimateNew(newEstimateValue)
        .build();
    issueClient.addWorklog(initialIssue.getWorklogUri(), worklogInput2, pm);

    // check if logged time has changed
    final Issue issueAfterSecondChange = issueClient.getIssue(issueKey, pm);
    final Integer actualTimeSpentAfterChange2 = getTimeSpentMinutesNotNull(issueAfterSecondChange.getTimeTracking());
    final Integer expectedTimeSpentAfterChange2 = getTimeSpentMinutesNotNull(issueAfterFirstChange.getTimeTracking()) + worklogInput2.getMinutesSpent();
    assertEquals(expectedTimeSpentAfterChange2, actualTimeSpentAfterChange2);

    // check if estimate has changed
    final Integer actualRemainingEstimate2 = getRemainingEstimateMinutesNotNull(issueAfterSecondChange.getTimeTracking());
    assertEquals(newEstimateValue, actualRemainingEstimate2);

    // # Third change - test leave
    final WorklogInput worklogInput3 = worklogInputBuilder
        .setIssueUri(initialIssue.getSelf())
        .setMinutesSpent(2)
        .setAdjustEstimateLeave()
        .build();
    issueClient.addWorklog(initialIssue.getWorklogUri(), worklogInput3, pm);

    // check if logged time has changed
    final Issue issueAfterThirdChange = issueClient.getIssue(issueKey, pm);
    final Integer actualTimeSpentAfterChange3 = getTimeSpentMinutesNotNull(issueAfterThirdChange.getTimeTracking());
    final Integer expectedTimeSpentAfterChange3 = getTimeSpentMinutesNotNull(issueAfterSecondChange.getTimeTracking()) + worklogInput3.getMinutesSpent();
    assertEquals(expectedTimeSpentAfterChange3, actualTimeSpentAfterChange3);

    // check if estimate has NOT changed
    final Integer actualRemainingEstimate3 = getRemainingEstimateMinutesNotNull(issueAfterThirdChange.getTimeTracking());
    final Integer expectedRemainingEstimate3 = getRemainingEstimateMinutesNotNull(issueAfterSecondChange.getTimeTracking());
    assertEquals(expectedRemainingEstimate3, actualRemainingEstimate3);

    // # Fourth change - test manual
    final int reduceByValueManual = 7;
    final WorklogInput worklogInput4 = worklogInputBuilder
        .setIssueUri(initialIssue.getSelf())
        .setMinutesSpent(2)
        .setAdjustEstimateManual(reduceByValueManual)
        .build();

    issueClient.addWorklog(initialIssue.getWorklogUri(), worklogInput4, pm);

    // check if logged time has changed
    final Issue issueAfterFourthChange = issueClient.getIssue(issueKey, pm);
    final Integer actualTimeSpentAfterChange4 = getTimeSpentMinutesNotNull(issueAfterFourthChange.getTimeTracking());
    final Integer expectedTimeSpentAfterChange4 = getTimeSpentMinutesNotNull(issueAfterThirdChange.getTimeTracking()) + worklogInput4.getMinutesSpent();
    assertEquals(expectedTimeSpentAfterChange4, actualTimeSpentAfterChange4);

    // check if estimate has NOT changed
    final Integer actualRemainingEstimate4 = getRemainingEstimateMinutesNotNull(issueAfterFourthChange.getTimeTracking());
    final Integer expectedRemainingEstimate4 = getRemainingEstimateMinutesNotNull(issueAfterThirdChange.getTimeTracking()) - reduceByValueManual;
    assertEquals(expectedRemainingEstimate4, actualRemainingEstimate4);
  }
View Full Code Here

    final WorklogInputBuilder worklogInputBuilder = createDefaulWorklogInputBuilder();
    final IssueRestClient issueClient = client.getIssueClient();

    // get issue
    final Issue initialIssue = issueClient.getIssue(issueKey, pm);

    // add worklog
    final int estimateWeeks = 2;
    final int estimateDays = 3;
    final int estimateHours = 4;
    final int estimateMinutes = 7;
    final WorklogInput worklogInput = worklogInputBuilder
        .setIssueUri(initialIssue.getSelf())
        .setAdjustEstimateNew(String.format("%sw %sd %sh %sm", estimateWeeks, estimateDays, estimateHours, estimateMinutes))
        .build();
    issueClient.addWorklog(initialIssue.getWorklogUri(), worklogInput, pm);

    // check if estimate has changed
    final Issue modifiedIssue = issueClient.getIssue(issueKey, pm);
    final int actualRemainingEstimate = getRemainingEstimateMinutesNotNull(modifiedIssue.getTimeTracking());
    // in current configuration 1w = 5d, 1d = 8h
    final int expectedRemaningEstimate = ((estimateWeeks * 5 + estimateDays) * 8 + estimateHours) * 60 + estimateMinutes;
    assertEquals(expectedRemaningEstimate, actualRemainingEstimate);
  }
View Full Code Here

  private void testAddWorklogImpl(String issueKey, WorklogInputBuilder worklogInputBuilder) {
    final IssueRestClient issueClient = client.getIssueClient();

    // get initial worklogs
    final Issue issue = issueClient.getIssue(issueKey, pm);
    final Set<Worklog> initialWorklogs = ImmutableSet.copyOf(issue.getWorklogs());

    // create and add new
    final WorklogInput worklogInput = worklogInputBuilder.setIssueUri(issue.getSelf()).build();
    issueClient.addWorklog(issue.getWorklogUri(), worklogInput, pm);

    // check if added correctly
    final Issue issueWithWorklog = issueClient.getIssue(issueKey, pm);
    final Worklog addedWorklog = getAddedWorklog(initialWorklogs, issueWithWorklog);
    assertEquals(worklogInput.getStartDate(), addedWorklog.getStartDate());
    assertEquals(worklogInput.getMinutesSpent(), addedWorklog.getMinutesSpent());
    assertEquals(worklogInput.getIssueUri(), addedWorklog.getIssueUri());
    assertEquals(worklogInput.getComment(), addedWorklog.getComment());
View Full Code Here

  public void testExample1() throws URISyntaxException, JSONException {
    // -- run the example
    Example1.main(new String[]{environmentData.getBaseUrl().toString(), "-q"});

    // -- check state after example
    final Issue issue = client.getIssueClient().getIssue("TST-7", ImmutableList.copyOf(IssueRestClient.Expandos.values()), pm);

    // votes
    final BasicVotes votes = issue.getVotes();
    assertNotNull(votes);
    assertEquals(1, votes.getVotes());
    assertEquals(true, votes.hasVoted());

    // watchers
    final BasicWatchers watchers = issue.getWatchers();
    assertNotNull(watchers);
    assertEquals(1, watchers.getNumWatchers());

    // resolution
    final BasicResolution resolution = issue.getResolution();
    assertNotNull(resolution);
    assertEquals("Incomplete", resolution.getName());

    if (isJira5xOrNewer()) {
      // changelog
      final Iterable<ChangelogGroup> changelog = issue.getChangelog();
      assertEquals(2, Iterables.size(changelog));
    }

    // comments
    final Iterable<Comment> comments = issue.getComments();
    assertNotNull(comments);
    assertEquals(1, Iterables.size(comments));
    final Comment comment = comments.iterator().next();
    assertEquals("My comment", comment.getBody());
    assertEquals("Administrator", comment.getAuthor().getDisplayName());
View Full Code Here

// Ignore "May produce NPE" warnings, as we know what we are doing in tests
@SuppressWarnings("ConstantConditions")
public class IssueJsonParserTest {
  @Test
  public void testParseIssue() throws Exception {
    final Issue issue = parseIssue("/json/issue/valid-all-expanded.json");
    assertExpectedIssue(issue);
    assertEquals(new BasicIssueType(toUri("http://localhost:8090/jira/rest/api/latest/issueType/1"), 1L, "Bug", false),
        issue.getIssueType());
  }
View Full Code Here

        issue.getIssueType());
  }

  @Test
  public void testParseIssueJira4x2() throws Exception {
    final Issue issue = parseIssue("/json/issue/valid-all-expanded-jira-4-2.json");
    assertExpectedIssue(issue);
    assertEquals(new BasicIssueType(toUri("http://localhost:8090/jira/rest/api/latest/issueType/1"), null, "Bug", false),
        issue.getIssueType());
  }
View Full Code Here

    return parser.parse(issueJson);
  }

  @Test
  public void testParseIssueWithResolution() throws JSONException {
    final Issue issue = parseIssue("/json/issue/valid-all-expanded-with-resolution.json");
    assertEquals("Incomplete", issue.getResolution().getName());

  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.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.