Search in sources :

Example 21 with Issue

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

the class IssueDaoTest method testLoadPagedByAuthor.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testLoadPagedByAuthor() {
    for (int i = 0; i < TEST_ISSUES_COUNT; i++) {
        EntityVO entity = new EntityVO(ENTITY_ID, ENTITY_CLASS);
        Issue issue = getIssue(NAME + i, entity);
        issueDao.createIssue(issue);
    }
    int maxPage = (int) Math.ceil((float) TEST_ISSUES_COUNT / TEST_PAGE_SIZE);
    Set<Long> seenIssueIds = new HashSet<>();
    for (int i = 1; i < maxPage + 1; i++) {
        List<Issue> issues = issueDao.loadIssuesByAuthor(AUTHOR, (long) i, TEST_PAGE_SIZE);
        assertFalse(issues.isEmpty());
        if (i < maxPage) {
            assertEquals(TEST_PAGE_SIZE, issues.size());
        }
        assertTrue(issues.stream().noneMatch(issue -> seenIssueIds.contains(issue.getId())));
        seenIssueIds.addAll(issues.stream().map(Issue::getId).collect(Collectors.toSet()));
    }
    assertEquals(TEST_ISSUES_COUNT, seenIssueIds.size());
    assertEquals(TEST_ISSUES_COUNT, issueDao.countIssuesByAuthor(AUTHOR));
}
Also used : Arrays(java.util.Arrays) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) IssueStatus(com.epam.pipeline.entity.issue.IssueStatus) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) List(java.util.List) Stream(java.util.stream.Stream) Propagation(org.springframework.transaction.annotation.Propagation) Assert.assertFalse(org.junit.Assert.assertFalse) Map(java.util.Map) Optional(java.util.Optional) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Issue(com.epam.pipeline.entity.issue.Issue) Assert.assertEquals(org.junit.Assert.assertEquals) EntityVO(com.epam.pipeline.controller.vo.EntityVO) Transactional(org.springframework.transaction.annotation.Transactional) EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with Issue

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

the class IssueCommentDaoTest method testCRUD.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUD() {
    Issue issue = createIssue(ISSUE_NAME);
    IssueComment comment = getComment(issue, COMMENT_TEXT);
    // create
    commentDao.createComment(comment);
    Long commentId = comment.getId();
    // load
    Optional<IssueComment> loaded = commentDao.loadComment(commentId);
    assertTrue(loaded.isPresent());
    verifyComment(comment, loaded.get());
    IssueComment comment2 = getComment(issue, COMMENT_TEXT2);
    commentDao.createComment(comment2);
    assertEquals(2, commentDao.loadCommentsForIssue(issue.getId()).size());
    // Load by multiple issue IDs
    Map<Long, List<IssueComment>> commentMap = commentDao.loadCommentsForIssues(Collections.singleton(issue.getId()));
    assertEquals(1, commentMap.size());
    assertEquals(2, commentMap.get(issue.getId()).size());
    // update
    comment.setText(COMMENT_TEXT3);
    commentDao.updateComment(comment);
    Optional<IssueComment> updated = commentDao.loadComment(commentId);
    assertTrue(updated.isPresent());
    assertEquals(COMMENT_TEXT3, updated.get().getText());
    // delete
    commentDao.deleteComment(comment.getId());
    Optional<IssueComment> deleted = commentDao.loadComment(commentId);
    assertFalse(deleted.isPresent());
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment) List(java.util.List) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with Issue

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

the class MetadataDaoTest method createItems.

private Pair<EntityVO, MetadataEntry> createItems(String issueName, AclClass aclClass, boolean createMetadata) {
    EntityVO entity = new EntityVO(1L, aclClass);
    Issue issue = getIssue(issueName, entity);
    issueDao.createIssue(issue);
    MetadataEntry metadataEntry = new MetadataEntry();
    if (createMetadata) {
        metadataEntry.setEntity(entity);
        metadataEntry.setData(new HashMap<>());
        metadataDao.registerMetadataItem(metadataEntry);
    }
    return new ImmutablePair<>(entity, metadataEntry);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry)

Example 24 with Issue

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

the class MetadataDaoTest method getIssue.

private Issue getIssue(String name, EntityVO entity) {
    Issue issue = new Issue();
    issue.setName(name);
    issue.setAuthor(AUTHOR);
    issue.setEntity(entity);
    issue.setText(TEXT);
    return issue;
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue)

Example 25 with Issue

use of com.epam.pipeline.entity.issue.Issue 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());
}
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)

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