Search in sources :

Example 6 with IssueCommentVO

use of com.epam.pipeline.controller.vo.IssueCommentVO 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)

Example 7 with IssueCommentVO

use of com.epam.pipeline.controller.vo.IssueCommentVO 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());
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) IssueVO(com.epam.pipeline.controller.vo.IssueVO) AttachmentDao(com.epam.pipeline.dao.issue.AttachmentDao) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Function(java.util.function.Function) Folder(com.epam.pipeline.entity.pipeline.Folder) ArgumentCaptor(org.mockito.ArgumentCaptor) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) Map(java.util.Map) FolderDao(com.epam.pipeline.dao.pipeline.FolderDao) IssueComment(com.epam.pipeline.entity.issue.IssueComment) Before(org.junit.Before) MockBean(org.springframework.boot.test.mock.mockito.MockBean) IssueCommentVO(com.epam.pipeline.controller.vo.IssueCommentVO) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) FolderManager(com.epam.pipeline.manager.pipeline.FolderManager) Assert.assertTrue(org.junit.Assert.assertTrue) IssueStatus(com.epam.pipeline.entity.issue.IssueStatus) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Attachment(com.epam.pipeline.entity.issue.Attachment) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) Mockito(org.mockito.Mockito) List(java.util.List) Stream(java.util.stream.Stream) IssueMapper(com.epam.pipeline.mapper.IssueMapper) Assert.assertFalse(org.junit.Assert.assertFalse) Preference(com.epam.pipeline.entity.preference.Preference) AclClass(com.epam.pipeline.entity.security.acl.AclClass) NotificationManager(com.epam.pipeline.manager.notification.NotificationManager) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) AuthManager(com.epam.pipeline.manager.security.AuthManager) Issue(com.epam.pipeline.entity.issue.Issue) Collections(java.util.Collections) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) Assert.assertEquals(org.junit.Assert.assertEquals) EntityVO(com.epam.pipeline.controller.vo.EntityVO) Transactional(org.springframework.transaction.annotation.Transactional) IssueCommentVO(com.epam.pipeline.controller.vo.IssueCommentVO) Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment) Attachment(com.epam.pipeline.entity.issue.Attachment) Date(java.util.Date) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with IssueCommentVO

use of com.epam.pipeline.controller.vo.IssueCommentVO in project cloud-pipeline by epam.

the class IssueManagerTest method creatingCommentForNonExistentIssueShouldThrowException.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void creatingCommentForNonExistentIssueShouldThrowException() {
    IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
    Long nonExistentIssueId = 1L;
    issueManager.createComment(nonExistentIssueId, commentVO);
}
Also used : IssueCommentVO(com.epam.pipeline.controller.vo.IssueCommentVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with IssueCommentVO

use of com.epam.pipeline.controller.vo.IssueCommentVO 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);
}
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 10 with IssueCommentVO

use of com.epam.pipeline.controller.vo.IssueCommentVO in project cloud-pipeline by epam.

the class IssueManagerTest method getCommentVO.

private IssueCommentVO getCommentVO(String text) {
    IssueCommentVO commentVO = new IssueCommentVO();
    commentVO.setText(text);
    return commentVO;
}
Also used : IssueCommentVO(com.epam.pipeline.controller.vo.IssueCommentVO)

Aggregations

IssueCommentVO (com.epam.pipeline.controller.vo.IssueCommentVO)16 Transactional (org.springframework.transaction.annotation.Transactional)14 Test (org.junit.Test)13 Issue (com.epam.pipeline.entity.issue.Issue)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 IssueComment (com.epam.pipeline.entity.issue.IssueComment)6 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)4 WithMockUser (org.springframework.security.test.context.support.WithMockUser)4 EntityVO (com.epam.pipeline.controller.vo.EntityVO)2 IssueVO (com.epam.pipeline.controller.vo.IssueVO)2 AttachmentDao (com.epam.pipeline.dao.issue.AttachmentDao)2 Attachment (com.epam.pipeline.entity.issue.Attachment)2 IssueStatus (com.epam.pipeline.entity.issue.IssueStatus)2 AclClass (com.epam.pipeline.entity.security.acl.AclClass)2 NotificationManager (com.epam.pipeline.manager.notification.NotificationManager)2 AuthManager (com.epam.pipeline.manager.security.AuthManager)2 IssueMapper (com.epam.pipeline.mapper.IssueMapper)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2