use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method createIssueWithAttachments.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void createIssueWithAttachments() throws InterruptedException {
when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
issueVO.setAttachments(Collections.singletonList(testAttachment));
Issue saved = issueManager.createIssue(issueVO);
Issue loaded = issueManager.loadIssue(saved.getId());
assertFalse(loaded.getAttachments().isEmpty());
issueManager.deleteIssue(loaded.getId());
assertFalse(attachmentDao.load(testAttachment.getId()).isPresent());
Thread.sleep(10);
verify(dataStorageManager).deleteDataStorageItems(Mockito.eq(testSystemDataStorage.getId()), Mockito.anyList(), Mockito.anyBoolean());
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method createCommentWithAttachments.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void createCommentWithAttachments() {
Issue issue = registerIssue();
Long issueId = issue.getId();
IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
commentVO.setAttachments(Collections.singletonList(testAttachment));
IssueComment comment = issueManager.createComment(issueId, commentVO);
IssueComment loaded = issueManager.loadComment(issueId, comment.getId());
Issue loadedIssue = issueManager.loadIssue(issueId);
assertEquals(1, loadedIssue.getComments().stream().mapToLong(c -> c.getAttachments().size()).sum());
assertFalse(loaded.getAttachments().isEmpty());
issueManager.deleteIssue(issueId);
assertFalse(attachmentDao.load(testAttachment.getId()).isPresent());
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method testCreateIssue.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateIssue() {
when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
Issue saved = issueManager.createIssue(issueVO);
Issue loaded = issueManager.loadIssue(saved.getId());
compareIssues(saved, loaded);
ArgumentCaptor<Issue> captor = ArgumentCaptor.forClass(Issue.class);
ArgumentCaptor<String> htmlTextCaptor = ArgumentCaptor.forClass(String.class);
verify(notificationManager).notifyIssue(captor.capture(), any(), htmlTextCaptor.capture());
assertEquals(ISSUE_TEXT, captor.getValue().getText());
assertEquals(ISSUE_TEXT, htmlTextCaptor.getValue());
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method testDeleteIssueWithComment.
@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteIssueWithComment() {
Issue issue = registerIssue();
Long issueId = issue.getId();
IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
issueManager.createComment(issueId, commentVO);
issueManager.deleteIssue(issueId);
issueManager.loadIssue(issueId);
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManager method loadIssueAndCheckIfNotClosed.
private Issue loadIssueAndCheckIfNotClosed(Long issueId) {
Issue issue = issueDao.loadIssue(issueId).orElseThrow(getIssueNotFoundException(issueId));
Assert.isTrue(!issue.getStatus().equals(IssueStatus.CLOSED), messageHelper.getMessage(MessageConstants.ERROR_ISSUE_STATUS_IS_CLOSED));
return issue;
}
Aggregations