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

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


  }

  @Test
  @JiraBuildNumberDependent(BN_JIRA_5)
  public void testAddCommentToIssueWithRoleLevelVisibility() {
    final Comment comment = Comment.createWithRoleLevel("Simple test comment restricted for role Administrators.",
        IntegrationTestUtil.ROLE_ADMINISTRATORS);
    final String issueKey = "ANONEDIT-1";
    final Comment addedComment = testAddCommentToIssueImpl(issueKey, comment);

    // try to get as anonymous user
    setAnonymousMode();

    final IssueRestClient issueClient = client.getIssueClient();
    final Issue issue = issueClient.getIssue(issueKey, pm);

    // test if we can see added comment
    assertFalse(hasComment(issue.getComments(), addedComment.getId()));
  }
View Full Code Here


    final Issue issueWithComments = issueClient.getIssue(issueKey, pm);
    final List<Comment> newComments = Lists.newArrayList(issueWithComments.getComments());
    newComments.removeAll(initialComments);
    assertEquals(1, Iterables.size(newComments));
    Comment addedComment = newComments.get(0);
    assertEquals(comment.getBody(), addedComment.getBody());
    assertEquals(comment.getVisibility(), addedComment.getVisibility());
    return addedComment;
  }
View Full Code Here

  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);
    assertEquals("some comment", comment1.getBody());
    assertEquals(TestConstants.USER_ADMIN, comment1.getAuthor());
    assertEquals(TestConstants.USER_ADMIN, comment1.getUpdateAuthor());
    assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getCreationDate());
    assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getUpdateDate());
    assertEquals(TestUtil.toUri("http://localhost:8090/jira/rest/api/latest/comment/10020"), comment1.getSelf());
    assertEquals(Long.valueOf(10020), comment1.getId());
    assertEquals(Visibility.role("Administrators"), comment1.getVisibility());

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

    final JSONObject comment2Json = commentsJson.getJSONArray("value").getJSONObject(1);
    final Comment comment2 = parser.parse(comment2Json);
    assertEquals(Long.valueOf(10021), comment2.getId());
    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);
    assertEquals("some comment", comment1.getBody());
    assertEquals(TestConstants.USER_ADMIN, comment1.getAuthor());
    assertEquals(TestConstants.USER_ADMIN, comment1.getUpdateAuthor());
    assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getCreationDate());
    assertEquals(TestUtil.toDateTime("2010-08-17T16:40:57.791+0200"), comment1.getUpdateDate());
    assertEquals(TestUtil.toUri("http://localhost:8090/jira/rest/api/latest/comment/10020"), comment1.getSelf());
    assertEquals(null, comment1.getId());
    assertEquals(Visibility.role("Administrators"), comment1.getVisibility());

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

    final JSONObject comment2Json = commentsJson.getJSONArray("value").getJSONObject(1);
    final Comment comment2 = parser.parse(comment2Json);
    assertEquals(null, comment2.getId());
    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);
    assertNull(comment.getAuthor());
    assertNull(comment.getUpdateAuthor());
    assertEquals("Comment from anonymous user", comment.getBody());

  }
View Full Code Here

  @Test
  public void testGetIssueWithNonTrivialComments() {
    final Issue issue = client.getIssueClient().getIssue("TST-2", pm);
    final Iterable<Comment> comments = issue.getComments();
    assertEquals(3, Iterables.size(comments));
    final Comment c1 = Iterables.get(comments, 0);
    assertEquals(Visibility.role("Administrators"), c1.getVisibility());

    final Comment c3 = Iterables.get(comments, 2);
    assertEquals(Visibility.group("jira-users"), c3.getVisibility());

  }
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

TOP

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