Search in sources :

Example 11 with Issue

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());
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) IssueVO(com.epam.pipeline.controller.vo.IssueVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with Issue

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());
}
Also used : IssueCommentVO(com.epam.pipeline.controller.vo.IssueCommentVO) Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with Issue

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());
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) IssueVO(com.epam.pipeline.controller.vo.IssueVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with Issue

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);
}
Also used : IssueCommentVO(com.epam.pipeline.controller.vo.IssueCommentVO) Issue(com.epam.pipeline.entity.issue.Issue) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with Issue

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;
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue)

Aggregations

Issue (com.epam.pipeline.entity.issue.Issue)44 Transactional (org.springframework.transaction.annotation.Transactional)30 Test (org.junit.Test)25 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)21 IssueComment (com.epam.pipeline.entity.issue.IssueComment)17 EntityVO (com.epam.pipeline.controller.vo.EntityVO)16 IssueCommentVO (com.epam.pipeline.controller.vo.IssueCommentVO)13 IssueVO (com.epam.pipeline.controller.vo.IssueVO)11 List (java.util.List)9 Attachment (com.epam.pipeline.entity.issue.Attachment)7 Map (java.util.Map)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 Propagation (org.springframework.transaction.annotation.Propagation)7 AclClass (com.epam.pipeline.entity.security.acl.AclClass)6 Collections (java.util.Collections)6 IssueStatus (com.epam.pipeline.entity.issue.IssueStatus)5 Collectors (java.util.stream.Collectors)5 AttachmentDao (com.epam.pipeline.dao.issue.AttachmentDao)4 AbstractSecuredEntity (com.epam.pipeline.entity.AbstractSecuredEntity)4 Folder (com.epam.pipeline.entity.pipeline.Folder)4