Search in sources :

Example 6 with Issue

use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.

the class IssueDaoTest method testLoadAndDeleteAllIssuesForEntity.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testLoadAndDeleteAllIssuesForEntity() {
    EntityVO entity = new EntityVO(ENTITY_ID, ENTITY_CLASS);
    Issue issue = getIssue(NAME, entity);
    issueDao.createIssue(issue);
    Issue issue2 = getIssue(NAME2, entity);
    issueDao.createIssue(issue2);
    // load
    List<Issue> actualIssues = issueDao.loadIssuesForEntity(entity);
    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 -> verifyIssue(expectedMap.get(i.getId()), i));
    // delete
    issueDao.deleteIssuesForEntity(entity);
    actualIssues = issueDao.loadIssuesForEntity(entity);
    assertEquals(0, actualIssues.size());
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Issue

use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.

the class IssueCommentDaoTest method createIssueComment.

private Issue createIssueComment(String issueName) {
    Issue issue = createIssue(issueName);
    IssueComment comment = getComment(issue, COMMENT_TEXT);
    commentDao.createComment(comment);
    return issue;
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment)

Example 8 with Issue

use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.

the class IssueCommentDaoTest method createIssue.

private Issue createIssue(String name) {
    EntityVO entityVO = new EntityVO(ENTITY_ID, ENTITY_CLASS);
    Issue issue = new Issue();
    issue.setName(name);
    issue.setAuthor(ISSUE_AUTHOR);
    issue.setEntity(entityVO);
    issue.setText(ISSUE_TEXT);
    issueDao.createIssue(issue);
    return issue;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue)

Example 9 with Issue

use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.

the class IssueCommentDaoTest method testDeleteCommentsForIssuesList.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteCommentsForIssuesList() {
    Issue issue = createIssueComment(ISSUE_NAME);
    Issue issue1 = createIssueComment(ISSUE_NAME1);
    List<Long> issuesToDelete = Stream.of(issue.getId(), issue1.getId()).collect(Collectors.toList());
    commentDao.deleteAllCommentsForIssuesList(issuesToDelete);
    assertEquals(0, commentDao.loadCommentsForIssue(issue.getId()).size());
    assertEquals(0, commentDao.loadCommentsForIssue(issue1.getId()).size());
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Issue

use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.

the class IssueManagerTest method testLoadIssueWithComments.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadIssueWithComments() {
    Issue issue = registerIssue();
    Long issueId = issue.getId();
    IssueCommentVO commentVO1 = getCommentVO(COMMENT_TEXT);
    IssueCommentVO commentVO2 = getCommentVO(COMMENT_TEXT2);
    issueManager.createComment(issueId, commentVO1);
    issueManager.createComment(issueId, commentVO2);
    assertEquals(2, issueManager.loadIssue(issueId).getComments().size());
}
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)

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