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));
}
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());
}
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);
}
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;
}
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());
}
Aggregations