use of com.epam.pipeline.controller.vo.IssueCommentVO 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.controller.vo.IssueCommentVO 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.controller.vo.IssueCommentVO in project cloud-pipeline by epam.
the class IssueManagerTest method creatingCommentForNonExistentIssueShouldThrowException.
@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void creatingCommentForNonExistentIssueShouldThrowException() {
IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
Long nonExistentIssueId = 1L;
issueManager.createComment(nonExistentIssueId, commentVO);
}
use of com.epam.pipeline.controller.vo.IssueCommentVO in project cloud-pipeline by epam.
the class IssueManagerTest method creatingCommentWithEmptyTextShouldThrowException.
@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void creatingCommentWithEmptyTextShouldThrowException() {
Issue issue = registerIssue();
Long issueId = issue.getId();
IssueCommentVO commentVO = getCommentVO("");
issueManager.createComment(issueId, commentVO);
}
use of com.epam.pipeline.controller.vo.IssueCommentVO in project cloud-pipeline by epam.
the class IssueManagerTest method getCommentVO.
private IssueCommentVO getCommentVO(String text) {
IssueCommentVO commentVO = new IssueCommentVO();
commentVO.setText(text);
return commentVO;
}
Aggregations