use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueCommentDaoTest method testCRUD.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUD() {
Issue issue = createIssue(ISSUE_NAME);
IssueComment comment = getComment(issue, COMMENT_TEXT);
// create
commentDao.createComment(comment);
Long commentId = comment.getId();
// load
Optional<IssueComment> loaded = commentDao.loadComment(commentId);
assertTrue(loaded.isPresent());
verifyComment(comment, loaded.get());
IssueComment comment2 = getComment(issue, COMMENT_TEXT2);
commentDao.createComment(comment2);
assertEquals(2, commentDao.loadCommentsForIssue(issue.getId()).size());
// Load by multiple issue IDs
Map<Long, List<IssueComment>> commentMap = commentDao.loadCommentsForIssues(Collections.singleton(issue.getId()));
assertEquals(1, commentMap.size());
assertEquals(2, commentMap.get(issue.getId()).size());
// update
comment.setText(COMMENT_TEXT3);
commentDao.updateComment(comment);
Optional<IssueComment> updated = commentDao.loadComment(commentId);
assertTrue(updated.isPresent());
assertEquals(COMMENT_TEXT3, updated.get().getText());
// delete
commentDao.deleteComment(comment.getId());
Optional<IssueComment> deleted = commentDao.loadComment(commentId);
assertFalse(deleted.isPresent());
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueCommentDaoTest method getComment.
public static IssueComment getComment(Issue issue, String commentText) {
IssueComment comment = new IssueComment();
comment.setIssueId(issue.getId());
comment.setAuthor(COMMENT_AUTHOR);
comment.setText(commentText);
return comment;
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueManagerTest method testCreateComment.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateComment() {
Issue issue = registerIssue();
Long issueId = issue.getId();
IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
IssueComment comment = issueManager.createComment(issueId, commentVO);
IssueComment loaded = issueManager.loadComment(issueId, comment.getId());
compareComments(comment, loaded);
ArgumentCaptor<IssueComment> captor = ArgumentCaptor.forClass(IssueComment.class);
ArgumentCaptor<String> htmlTextCaptor = ArgumentCaptor.forClass(String.class);
verify(notificationManager).notifyIssueComment(captor.capture(), any(), htmlTextCaptor.capture());
assertEquals(COMMENT_TEXT, captor.getValue().getText());
assertEquals(COMMENT_TEXT, htmlTextCaptor.getValue());
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueManagerTest method updateCommentWithAttachments.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void updateCommentWithAttachments() throws InterruptedException {
Attachment newAttachment = new Attachment();
newAttachment.setPath("///");
newAttachment.setName("newTestAttachment");
newAttachment.setCreatedDate(new Date());
newAttachment.setOwner(AUTHOR);
attachmentDao.createAttachment(newAttachment);
Issue issue = registerIssue();
Long issueId = issue.getId();
IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
IssueComment comment = issueManager.createComment(issueId, commentVO);
IssueCommentVO updated = new IssueCommentVO();
updated.setText(COMMENT_TEXT2);
updated.setAttachments(Collections.singletonList(newAttachment));
Long commentId = comment.getId();
issueManager.updateComment(issueId, comment.getId(), updated);
IssueComment loaded = issueManager.loadComment(issueId, commentId);
assertEquals(1, loaded.getAttachments().size());
assertTrue(loaded.getAttachments().stream().allMatch(a -> a.getName().equals(newAttachment.getName())));
issueManager.deleteComment(issueId, commentId);
assertFalse(attachmentDao.load(newAttachment.getId()).isPresent());
Thread.sleep(TIMEOUT);
verify(dataStorageManager, Mockito.times(2)).deleteDataStorageItems(Mockito.eq(testSystemDataStorage.getId()), Mockito.anyList(), Mockito.anyBoolean());
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueManagerTest method testDeleteComment.
@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteComment() {
IssueComment comment = registerComment();
Long issueId = comment.getIssueId();
Long commentId = comment.getId();
issueManager.deleteComment(issueId, commentId);
issueManager.loadComment(issueId, commentId);
}
Aggregations