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

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


  public void testParse() throws Exception {
    final JSONObject commentsJson = ResourceUtil.getJsonObjectFromResource("/json/comment/valid.json");
    final CommentJsonParser parser = new CommentJsonParser();

    final JSONObject comment1Json = commentsJson.getJSONArray("value").getJSONObject(0);
    final Comment comment1 = parser.parse(comment1Json);
    Assert.assertEquals("some comment", comment1.getBody());
    Assert.assertEquals(TestConstants.USER_ADMIN_BASIC_DEPRECATED, comment1.getAuthor());
    Assert.assertEquals(TestConstants.USER_ADMIN_BASIC_DEPRECATED, comment1.getUpdateAuthor());
    Assert.assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getCreationDate());
    Assert.assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getUpdateDate());
    Assert.assertEquals(TestUtil.toUri("http://localhost:8090/jira/rest/api/latest/comment/10020"), comment1.getSelf());
    Assert.assertEquals(Long.valueOf(10020), comment1.getId());
    Assert.assertEquals(Visibility.role("Administrators"), comment1.getVisibility());

    final JSONObject comment3Json = commentsJson.getJSONArray("value").getJSONObject(2);
    final Comment comment3 = parser.parse(comment3Json);
    Assert.assertEquals(Long.valueOf(10022), comment3.getId());
    Assert.assertEquals(Visibility.group("jira-users"), comment3.getVisibility());

    final JSONObject comment2Json = commentsJson.getJSONArray("value").getJSONObject(1);
    final Comment comment2 = parser.parse(comment2Json);
    Assert.assertEquals(Long.valueOf(10021), comment2.getId());
    Assert.assertNull(comment2.getVisibility());
  }
View Full Code Here


  public void testParseWithoutId() throws Exception {
    final JSONObject commentsJson = ResourceUtil.getJsonObjectFromResource("/json/comment/valid-without-id.json");
    final CommentJsonParser parser = new CommentJsonParser();

    final JSONObject comment1Json = commentsJson.getJSONArray("value").getJSONObject(0);
    final Comment comment1 = parser.parse(comment1Json);
    Assert.assertEquals("some comment", comment1.getBody());
    Assert.assertEquals(TestConstants.USER_ADMIN_BASIC_DEPRECATED, comment1.getAuthor());
    Assert.assertEquals(TestConstants.USER_ADMIN_BASIC_DEPRECATED, comment1.getUpdateAuthor());
    Assert.assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getCreationDate());
    Assert.assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getUpdateDate());
    Assert.assertEquals(TestUtil.toUri("http://localhost:8090/jira/rest/api/latest/comment/10020"), comment1.getSelf());
    Assert.assertEquals(null, comment1.getId());
    Assert.assertEquals(Visibility.role("Administrators"), comment1.getVisibility());

    final JSONObject comment3Json = commentsJson.getJSONArray("value").getJSONObject(2);
    final Comment comment3 = parser.parse(comment3Json);
    Assert.assertEquals(null, comment3.getId());
    Assert.assertEquals(Visibility.group("jira-users"), comment3.getVisibility());

    final JSONObject comment2Json = commentsJson.getJSONArray("value").getJSONObject(1);
    final Comment comment2 = parser.parse(comment2Json);
    Assert.assertEquals(null, comment2.getId());
    Assert.assertNull(comment2.getVisibility());

  }
View Full Code Here

  @Test
  public void testParseAnonymous() throws JSONException {
    final CommentJsonParser parser = new CommentJsonParser();
    final JSONObject json = ResourceUtil.getJsonObjectFromResource("/json/comment/valid-anonymous.json");
    final JSONObject commentJson = json.getJSONArray("value").getJSONObject(0);
    final Comment comment = parser.parse(commentJson);
    Assert.assertNull(comment.getAuthor());
    Assert.assertNull(comment.getUpdateAuthor());
    Assert.assertEquals("Comment from anonymous user", comment.getBody());

  }
View Full Code Here

    });
  }

  @Test
  public void testTransitionWithNoRoleOrGroup() {
    Comment comment = Comment.valueOf("My text which I am just adding " + new DateTime());
    testTransitionImpl(comment);
  }
View Full Code Here

    testTransitionImpl(comment);
  }

  @Test
  public void testTransitionWithRoleLevel() {
    Comment comment = Comment.createWithRoleLevel("My text which I am just adding " + new DateTime(), "Users");
    testTransitionImpl(comment);
  }
View Full Code Here

    testTransitionImpl(comment);
  }

  @Test
  public void testTransitionWithGroupLevel() {
    Comment comment = Comment.createWithGroupLevel("My text which I am just adding " + new DateTime(), "jira-users");
    testTransitionImpl(comment);
  }
View Full Code Here

    testTransitionImpl(comment);
  }

  @Test
  public void testTransitionWithInvalidRole() {
    final Comment comment = Comment.createWithRoleLevel("My text which I am just adding " + new DateTime(), "some-fake-role");
    if (IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER) {
      assertInvalidCommentInput(comment, "Invalid role level specified.");
    } else {
      assertInvalidCommentInput(comment, "Invalid role [some-fake-role]");
    }
View Full Code Here

    }
  }

  @Test
  public void testTransitionWithInvalidGroup() {
    final Comment comment = Comment.createWithGroupLevel(
        "My text which I am just adding " + new DateTime(), "some-fake-group");
    assertInvalidCommentInput(comment, "Group: some-fake-group does not exist.");
  }
View Full Code Here

    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));
    assertEquals(comment.getVisibility(), lastComment.getVisibility());
  }
View Full Code Here

    assertEquals(IssueLinkType.Direction.OUTBOUND, addedLink.getIssueLinkType().getDirection());

    final int expectedNumComments = commentInput != null ? origNumComments + 1 : origNumComments;
    assertEquals(expectedNumComments, Iterables.size(linkedIssue.getComments()));
    if (commentInput != null) {
      final Comment comment = linkedIssue.getComments().iterator().next();
      assertEquals(commentInput.getBody(), comment.getBody());
      assertEquals(IntegrationTestUtil.USER_ADMIN, comment.getAuthor());
      assertEquals(commentInput.getVisibility(), comment.getVisibility());
    } else {
      assertFalse(linkedIssue.getComments().iterator().hasNext());
    }

View Full Code Here

TOP

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

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.