use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method testLoadAndDeleteIssuesForEntity.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadAndDeleteIssuesForEntity() {
when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
issueVO.setAttachments(Collections.singletonList(testAttachment));
Issue issue = issueManager.createIssue(issueVO);
Issue issue2 = issueManager.createIssue(getIssueVO(ISSUE_NAME2, ISSUE_TEXT, entityVO));
// load
List<Issue> actualIssues = issueManager.loadIssuesForEntity(entityVO);
assertEquals(2, actualIssues.size());
List<Issue> expectedIssues = Stream.of(issue, issue2).collect(Collectors.toList());
Map<Long, Issue> expectedMap = expectedIssues.stream().collect(Collectors.toMap(Issue::getId, Function.identity()));
actualIssues.forEach(i -> compareIssues(expectedMap.get(i.getId()), i));
// delete
issueManager.deleteIssuesForEntity(entityVO);
actualIssues = issueManager.loadIssuesForEntity(entityVO);
assertEquals(0, actualIssues.size());
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method testDeleteIssuesWhenEntityWasDeleted.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteIssuesWhenEntityWasDeleted() {
when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
Folder folder = new Folder();
folder.setName(FOLDER_NAME_2);
folder.setOwner(AUTHOR);
folderDao.createFolder(folder);
EntityVO entityVO = new EntityVO(folder.getId(), AclClass.FOLDER);
IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
issueManager.createIssue(issueVO);
folderManager.delete(folder.getId());
List<Issue> issues = issueManager.loadIssuesForEntity(entityVO);
assertTrue(CollectionUtils.isEmpty(issues));
}
use of com.epam.pipeline.entity.issue.Issue 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.Issue 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.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueManagerTest method testDeleteIssuesForNonExistingEntity.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteIssuesForNonExistingEntity() {
List<Issue> issues = issueManager.deleteIssuesForEntity(new EntityVO(1L, AclClass.FOLDER));
assertTrue(CollectionUtils.isEmpty(issues));
}
Aggregations