Search in sources :

Example 11 with IssueVO

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

the class IssueManagerTest method getIssueVO.

private IssueVO getIssueVO(String name, String text, EntityVO entity) {
    IssueVO issueVO = new IssueVO();
    issueVO.setName(name);
    issueVO.setEntity(entity);
    issueVO.setText(text);
    issueVO.setLabels(Arrays.asList(LABEL1, LABEL2));
    return issueVO;
}
Also used : IssueVO(com.epam.pipeline.controller.vo.IssueVO)

Example 12 with IssueVO

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

the class IssueManagerTest method updateIssueWithAttachments.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void updateIssueWithAttachments() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    issueVO.setStatus(IssueStatus.OPEN);
    issueVO.setAttachments(Collections.singletonList(testAttachment));
    Issue saved = issueManager.createIssue(issueVO);
    Attachment newAttachment = new Attachment();
    newAttachment.setPath("///");
    newAttachment.setName("newTestAttachment");
    newAttachment.setCreatedDate(new Date());
    newAttachment.setOwner(AUTHOR);
    attachmentDao.createAttachment(newAttachment);
    issueVO.setAttachments(Collections.singletonList(newAttachment));
    issueManager.updateIssue(saved.getId(), issueVO);
    Issue loaded = issueManager.loadIssue(saved.getId());
    assertEquals(1, loaded.getAttachments().size());
    assertTrue(loaded.getAttachments().stream().allMatch(a -> a.getName().equals(newAttachment.getName())));
}
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) Issue(com.epam.pipeline.entity.issue.Issue) Attachment(com.epam.pipeline.entity.issue.Attachment) IssueVO(com.epam.pipeline.controller.vo.IssueVO) Date(java.util.Date) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with IssueVO

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

the class IssueManagerTest method getClosedIssue.

private Issue getClosedIssue() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    Issue issue = issueManager.createIssue(issueVO);
    issueVO.setStatus(IssueStatus.CLOSED);
    return issueManager.updateIssue(issue.getId(), issueVO);
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) IssueVO(com.epam.pipeline.controller.vo.IssueVO)

Example 14 with IssueVO

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

the class IssueManagerTest method testUpdateIssue.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testUpdateIssue() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    Issue saved = issueManager.createIssue(issueVO);
    issueVO.setName(ISSUE_NAME2);
    issueVO.setText(ISSUE_TEXT2);
    issueVO.setStatus(IssueStatus.OPEN);
    issueVO.setLabels(Arrays.asList(LABEL1, LABEL2, LABEL3));
    Long issueId = saved.getId();
    issueManager.updateIssue(issueId, issueVO);
    Issue updated = issueMapper.toIssue(issueVO);
    updated.setAuthor(AUTHOR);
    compareIssues(issueManager.loadIssue(issueId), updated);
}
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 15 with IssueVO

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

the class IssueManagerTest method updatingClosedIssueShouldThrowException.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void updatingClosedIssueShouldThrowException() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    Issue closedIssue = getClosedIssue();
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    issueVO.setLabels(Collections.singletonList(LABEL1));
    issueManager.updateIssue(closedIssue.getId(), issueVO);
}
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)

Aggregations

IssueVO (com.epam.pipeline.controller.vo.IssueVO)16 Transactional (org.springframework.transaction.annotation.Transactional)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)10 Test (org.junit.Test)10 Issue (com.epam.pipeline.entity.issue.Issue)9 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5 IssueCommentVO (com.epam.pipeline.controller.vo.IssueCommentVO)2 AttachmentDao (com.epam.pipeline.dao.issue.AttachmentDao)2 Attachment (com.epam.pipeline.entity.issue.Attachment)2 IssueComment (com.epam.pipeline.entity.issue.IssueComment)2 IssueStatus (com.epam.pipeline.entity.issue.IssueStatus)2 Folder (com.epam.pipeline.entity.pipeline.Folder)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 Collectors (java.util.stream.Collectors)2