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

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


  @Override
  public BasicIssue parse(JSONObject json) throws JSONException {
    final URI selfUri = JsonParseUtil.getSelfUri(json);
    final String key = json.getString("key");
    final Long id = json.getLong("id");
    return new BasicIssue(selfUri, key, id);
  }
View Full Code Here


    return fieldJson.toString(); // JIRA 5.0 way
  }

  @Override
  public Issue parse(final JSONObject s) throws JSONException {
    final BasicIssue basicIssue = basicIssueJsonParser.parse(s);
    final Iterable<String> expandos = parseExpandos(s);
    final JSONObject jsonFields = s.getJSONObject(FIELDS);
    final JSONObject commentsJson = jsonFields.optJSONObject(COMMENT_FIELD.id);
    final Collection<Comment> comments = (commentsJson == null) ? Collections.<Comment>emptyList()
        : parseArray(commentsJson, new JsonWeakParserForJsonObject<Comment>(commentJsonParser), "comments");

    final String summary = getFieldStringValue(s, SUMMARY_FIELD.id);
    final String description = getOptionalFieldStringUnisex(s, DESCRIPTION_FIELD.id);

    final Collection<Attachment> attachments = parseOptionalArray(s, new JsonWeakParserForJsonObject<Attachment>(attachmentJsonParser), FIELDS, ATTACHMENT_FIELD.id);
    final Collection<IssueField> fields = parseFields(s);

    final BasicIssueType issueType = issueTypeJsonParser.parse(getFieldUnisex(s, ISSUE_TYPE_FIELD.id));
    final DateTime creationDate = JsonParseUtil.parseDateTime(getFieldStringUnisex(s, CREATED_FIELD.id));
    final DateTime updateDate = JsonParseUtil.parseDateTime(getFieldStringUnisex(s, UPDATED_FIELD.id));

    final String dueDateString = getOptionalFieldStringUnisex(s, DUE_DATE_FIELD.id);
    final DateTime dueDate = dueDateString == null ? null : JsonParseUtil.parseDateTimeOrDate(dueDateString);

    final BasicPriority priority = getOptionalNestedField(s, PRIORITY_FIELD.id, priorityJsonParser);
    final BasicResolution resolution = getOptionalNestedField(s, RESOLUTION_FIELD.id, resolutionJsonParser);
    final User assignee = getOptionalNestedField(s, ASSIGNEE_FIELD.id, userJsonParser);
    final User reporter = getOptionalNestedField(s, REPORTER_FIELD.id, userJsonParser);

    final BasicProject project = projectJsonParser.parse(getFieldUnisex(s, PROJECT_FIELD.id));
    final Collection<IssueLink> issueLinks;
    issueLinks = parseOptionalArray(s, new JsonWeakParserForJsonObject<IssueLink>(issueLinkJsonParserV5), FIELDS, LINKS_FIELD.id);

    Collection<Subtask> subtasks = parseOptionalArray(s, new JsonWeakParserForJsonObject<Subtask>(subtaskJsonParser), FIELDS, SUBTASKS_FIELD.id);

    final BasicVotes votes = getOptionalNestedField(s, VOTES_FIELD.id, votesJsonParser);
    final BasicStatus status = statusJsonParser.parse(getFieldUnisex(s, STATUS_FIELD.id));

    final Collection<Version> fixVersions = parseOptionalArray(s, new JsonWeakParserForJsonObject<Version>(versionJsonParser), FIELDS, FIX_VERSIONS_FIELD.id);
    final Collection<Version> affectedVersions = parseOptionalArray(s, new JsonWeakParserForJsonObject<Version>(versionJsonParser), FIELDS, AFFECTS_VERSIONS_FIELD.id);
    final Collection<BasicComponent> components = parseOptionalArray(s, new JsonWeakParserForJsonObject<BasicComponent>(basicComponentJsonParser), FIELDS, COMPONENTS_FIELD.id);

    final Collection<Worklog> worklogs;
    final URI selfUri = basicIssue.getSelf();

    final String transitionsUriString;
    if (s.has(IssueFieldId.TRANSITIONS_FIELD.id)) {
      Object transitionsObj = s.get(IssueFieldId.TRANSITIONS_FIELD.id);
      transitionsUriString = (transitionsObj instanceof String) ? (String) transitionsObj : null;
    } else {
      transitionsUriString = getOptionalFieldStringUnisex(s, IssueFieldId.TRANSITIONS_FIELD.id);
    }
    final URI transitionsUri = parseTransisionsUri(transitionsUriString, selfUri);

    if (JsonParseUtil.getNestedOptionalObject(s, FIELDS, WORKLOG_FIELD.id) != null) {
      worklogs = parseOptionalArray(s,
          new JsonWeakParserForJsonObject<Worklog>(new WorklogJsonParserV5(selfUri)),
          FIELDS, WORKLOG_FIELD.id, WORKLOGS_FIELD.id);
    } else {
      worklogs = Collections.emptyList();
    }


    final BasicWatchers watchers = getOptionalNestedField(s, WATCHER_FIELD.id, watchersJsonParser);
    final TimeTracking timeTracking = getOptionalNestedField(s, TIMETRACKING_FIELD.id, new TimeTrackingJsonParserV5());

    final Set<String> labels = Sets
        .newHashSet(parseOptionalArrayNotNullable(s, jsonWeakParserForString, FIELDS, LABELS_FIELD.id));

    final Collection<ChangelogGroup> changelog = parseOptionalArray(
        s, new JsonWeakParserForJsonObject<ChangelogGroup>(changelogJsonParser), "changelog", "histories");
    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, labels);
  }
View Full Code Here

public class BasicIssueJsonParserTest {

  @Test
  public void testParse() throws Exception {
    BasicIssueJsonParser parser = new BasicIssueJsonParser();
    final BasicIssue actual = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/basicIssue/valid.json"));
    final BasicIssue expected = new BasicIssue(toUri("http://localhost:8090/jira/rest/api/latest/issue/10040"), "TST-7", 10040l);
    assertEquals(expected, actual);
  }
View Full Code Here

    // verify that issue exist and create subtask
    final String issueKey = "TST-1";
    final Issue issue = issueClient.getIssue(issueKey).claim();
    assertEquals(issueKey, issue.getKey());
    final BasicIssue subtask = addSubtaskToIssue(issue);
    System.out.println(subtask);

    // delete issue
    issueClient.deleteIssue(issueKey, true).claim();

    // verify
    assertThatIssueNotExists(issueKey);
    assertThatIssueNotExists(subtask.getKey());
  }
View Full Code Here

    // verify that issue exist and create subtask
    final String issueKey = "TST-1";
    final Issue issue = issueClient.getIssue(issueKey).claim();
    assertEquals(issueKey, issue.getKey());
    BasicIssue subtask = addSubtaskToIssue(issue);
    System.out.println(subtask);

    // delete issue
    expectedException.expect(rceWithSingleError(400, String.format("The issue '%s' has subtasks.  "
        + "You must specify the 'deleteSubtasks' parameter to delete this issue and all its subtasks.", issueKey)));
View Full Code Here

    final IssueInputBuilder issueInputBuilder = new IssueInputBuilder(project, issueType, summary)
        .setDescription(description)
        .setFieldValue("parent", ComplexIssueInputFieldValue.with("key", issue.getKey()));

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

    return basicCreatedIssue;
  }
View Full Code Here

        .setDueDate(dueDate)
        .setPriority(priority)
        .setFieldValue(multiUserCustomFieldId, multiUserCustomFieldValues);

    // 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());
View Full Code Here

        .setDueDate(dueDate)
        .setPriority(priority)
        .setFieldValue("parent", ComplexIssueInputFieldValue.with("key", "TST-1"));

    // 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());
View Full Code Here

    // build issue input
    final String summary = "My new issue!";

    // create
    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

    setAnonymousMode();

    final IssueRestClient issueClient = client.getIssueClient();

    final IssueInput issueInput = new IssueInputBuilder("ANONEDIT", 1L, "Anonymously created issue").build();
    final BasicIssue createdIssue = issueClient.createIssue(issueInput).claim();

    assertNotNull(createdIssue);
    assertNotNull(createdIssue.getKey());
  }
View Full Code Here

TOP

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

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.