use of com.enonic.xp.issue.CreateIssueCommentParams in project xp by enonic.
the class IssueServiceImplTest_updateComment method updateComment.
@Test
public void updateComment() throws Exception {
Issue issue = this.createIssue(CreateIssueParams.create().title("issue-1"));
final Instant created = Instant.now().minus(1, ChronoUnit.MINUTES);
final PrincipalKey creator = PrincipalKey.from("user:store:me");
final String creatorDisplayName = "Me Myself";
final CreateIssueCommentParams params = CreateIssueCommentParams.create().text("text").issue(issue.getId()).creator(creator).creatorDisplayName(creatorDisplayName).created(created).build();
final IssueComment comment = this.issueService.createComment(params);
final IssueComment updatedComment = this.issueService.updateComment(UpdateIssueCommentParams.create().comment(comment.getId()).text("updated text").build());
assertNotNull(updatedComment);
assertEquals("updated text", updatedComment.getText());
assertEquals(creator, updatedComment.getCreator());
assertEquals(creatorDisplayName, updatedComment.getCreatorDisplayName());
assertEquals(created, updatedComment.getCreated());
}
use of com.enonic.xp.issue.CreateIssueCommentParams in project xp by enonic.
the class CreateIssueCommentCommandTest method create.
@Test
public void create() {
final Node issueNode = Node.create().name("parent-issue").build();
final PrincipalKey creator = PrincipalKey.from("user:store:one");
final CreateIssueCommentParams params = CreateIssueCommentParams.create().issue(IssueId.create()).creator(creator).creatorDisplayName("Creator One").text("Comment text...").build();
final CreateIssueCommentCommand command = createIssueCommentCommand(params);
Mockito.when(this.nodeService.findByQuery(Mockito.any(NodeQuery.class))).thenReturn(FindNodesByQueryResult.create().build());
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(issueNode);
final IssueComment comment = command.execute();
assertNotNull(comment);
assertEquals("Comment text...", comment.getText());
assertEquals(creator, comment.getCreator());
assertEquals("Creator One", comment.getCreatorDisplayName());
}
use of com.enonic.xp.issue.CreateIssueCommentParams in project xp by enonic.
the class CreateIssueCommentCommandTest method createIssueNotExists.
@Test
public void createIssueNotExists() {
final PrincipalKey creator = PrincipalKey.from("user:store:one");
final CreateIssueCommentParams params = CreateIssueCommentParams.create().creator(creator).issue(IssueId.create()).creatorDisplayName("Creator One").text("Comment text...").build();
final CreateIssueCommentCommand command = createIssueCommentCommand(params);
Mockito.when(this.nodeService.findByQuery(Mockito.any(NodeQuery.class))).thenReturn(FindNodesByQueryResult.create().build());
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenThrow(new NodeNotFoundException("Node not found"));
assertThrows(NodeNotFoundException.class, () -> command.execute());
}
use of com.enonic.xp.issue.CreateIssueCommentParams in project xp by enonic.
the class CreateIssueCommentCommandTest method testNoIssueId.
@Test
public void testNoIssueId() {
final CreateIssueCommentParams params = CreateIssueCommentParams.create().text("text").build();
final CreateIssueCommentCommand command = createIssueCommentCommand(params);
assertThrows(IllegalArgumentException.class, () -> command.execute());
}
use of com.enonic.xp.issue.CreateIssueCommentParams in project xp by enonic.
the class IssueCommentDataSerializerTest method testCreate.
@Test
public void testCreate() {
final CreateIssueCommentParams params = CreateIssueCommentParams.create().issue(IssueId.create()).creator(creator).creatorDisplayName("Creator One").text("Comment text...").created(createdTime).build();
final PropertyTree data = serializer.toCreateNodeData(params);
assertNotNull(data);
assertEquals("Comment text...", data.getString(TEXT));
assertEquals("Creator One", data.getString(CREATOR_DISPLAY_NAME));
assertEquals(creator.toString(), data.getString(CREATOR));
assertEquals(createdTime, data.getInstant(CREATED_TIME));
}
Aggregations