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

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


    final IssueInput issueInput = new IssueInputBuilder(project, issueType, summary).build();
    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInput).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());
  }
View Full Code Here


    final IssueInput issueInput = builder.build();

    final BasicIssue basicCreatedIssue = issueClient.createIssue(issueInput).claim();
    assertNotNull(basicCreatedIssue);

    final Issue createdIssue = issueClient.getIssue(basicCreatedIssue.getKey()).claim();
    assertNotNull(createdIssue);

    log.log("Created new issue successfully, key: " + basicCreatedIssue.getKey());

    // assert few fields
    IssueInputBuilder actualBuilder = new IssueInputBuilder(createdIssue.getProject(), createdIssue
        .getIssueType(), createdIssue.getSummary())
        .setPriority(createdIssue.getPriority())
        .setReporter(createdIssue.getReporter())
        .setAssignee(createdIssue.getAssignee())
        .setDescription(createdIssue.getDescription());

    final Collection<FieldInput> actualValues = actualBuilder.build().getFields().values();
    final Collection<FieldInput> expectedValues = issueInput.getFields().values();

    assertThat(expectedValues, hasItems(toArray(actualValues, FieldInput.class)));
View Full Code Here

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

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

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

    // check if estimate has changed
    final Issue issueAfterFirstChange = issueClient.getIssue(issueKey).claim();
    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).claim();

    // check if logged time has changed
    final Issue issueAfterSecondChange = issueClient.getIssue(issueKey).claim();
    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).claim();

    // check if logged time has changed
    final Issue issueAfterThirdChange = issueClient.getIssue(issueKey).claim();
    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).claim();

    // check if logged time has changed
    final Issue issueAfterFourthChange = issueClient.getIssue(issueKey).claim();
    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).claim();

    // 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).claim();

    // check if estimate has changed
    final Issue modifiedIssue = issueClient.getIssue(issueKey).claim();
    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).claim();
    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).claim();

    // check if added correctly
    final Issue issueWithWorklog = issueClient.getIssue(issueKey).claim();
    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

    final Collection<ChangelogGroup> changelog = parseOptionalArray(
        issueJson, new JsonWeakParserForJsonObject<ChangelogGroup>(changelogJsonParser), "changelog", "histories");
    final Operations operations = parseOptionalJsonObject(issueJson, "operations", operationsJsonParser);

    return new Issue(summary, selfUri, 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, operations, labels);
  }
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

  }

  @Test
  public void testAddWatcherUnauthorized() {
    final IssueRestClient issueClient = client.getIssueClient();
    final Issue issue1 = issueClient.getIssue("TST-1").claim();
    issueClient.addWatcher(issue1.getWatchers().getSelf(), USER1_USERNAME).claim();
    assertThat(client.getIssueClient().getWatchers(issue1.getWatchers().getSelf()).claim()
        .getUsers(), hasItem(IntegrationTestUtil.USER1));

    setUser1();
    assertTrue(client.getIssueClient().getIssue("TST-1").claim().getWatchers().isWatching());
    String expectedErrorMsg = isJraDev3516Fixed() ? ("User '" + USER1_USERNAME
        + "' is not allowed to add watchers to issue 'TST-1'") : null;
    assertErrorCode(Response.Status.UNAUTHORIZED, expectedErrorMsg, new Runnable() {
      @Override
      public void run() {
        client.getIssueClient().addWatcher(issue1.getWatchers().getSelf(), ADMIN_USERNAME).claim();
      }
    });
  }
View Full Code Here

  @Test
  public void testAddWatcherWhoDoesNotHaveViewIssuePermissions() {
    final IssueRestClient issueClient = client.getIssueClient();
    final String issueKey = "RST-1";
    final Issue issue1 = issueClient.getIssue(issueKey).claim();
    final String expectedErrorMessage;

    if (isJira5xOrNewer()) {
      expectedErrorMessage = "The user \"" + USER2_USERNAME + "\" does not have permission to view this issue."
          + " This user will not be added to the watch list.";
    } else if (isJira43xOrNewer()) {
      expectedErrorMessage = "User '" + ADMIN_USERNAME + "' is not allowed to add watchers to issue '" + issueKey + "'";
    } else {
      expectedErrorMessage = "com.sun.jersey.api.client.UniformInterfaceException: Client response status: 401";
    }

    assertErrorCode(Response.Status.UNAUTHORIZED, expectedErrorMessage,
        new Runnable() {
          @Override
          public void run() {
            issueClient.addWatcher(issue1.getWatchers().getSelf(), USER2_USERNAME).claim();
          }
        });
  }
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.