use of com.epam.pipeline.controller.vo.IssueVO in project cloud-pipeline by epam.
the class IssueManager method updateIssue.
/**
* Updates an {@link Issue} specified by ID. If issue was closed or doesn't exist an error will be occurred.
* @param issueId issue ID
* @param issueVO issue content to update
* @return updated issue
*/
@Transactional(propagation = Propagation.REQUIRED)
public Issue updateIssue(Long issueId, IssueVO issueVO) {
validateIssueParameters(issueVO);
Issue existingIssue = loadIssueAndCheckIfNotClosed(issueId);
Issue issue = updateIssueObject(existingIssue, issueVO);
issueDao.updateIssue(issue);
// Find the attachments that were removed during update and delete them
HashSet<Attachment> newAttachments = new HashSet<>(issueVO.getAttachments());
List<Attachment> allAttachments = attachmentDao.loadAttachmentsByIssueId(issueId);
List<Attachment> toDelete = allAttachments.stream().filter(a -> !newAttachments.contains(a)).collect(Collectors.toList());
attachmentFileManager.deleteAttachments(toDelete);
// Link new attachments to this issue
issueVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentIssueId(a.getId(), issueId));
return issue;
}
use of com.epam.pipeline.controller.vo.IssueVO in project cloud-pipeline by epam.
the class IssueManagerTest method createIssueWithAttachments.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void createIssueWithAttachments() throws InterruptedException {
when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
issueVO.setAttachments(Collections.singletonList(testAttachment));
Issue saved = issueManager.createIssue(issueVO);
Issue loaded = issueManager.loadIssue(saved.getId());
assertFalse(loaded.getAttachments().isEmpty());
issueManager.deleteIssue(loaded.getId());
assertFalse(attachmentDao.load(testAttachment.getId()).isPresent());
Thread.sleep(10);
verify(dataStorageManager).deleteDataStorageItems(Mockito.eq(testSystemDataStorage.getId()), Mockito.anyList(), Mockito.anyBoolean());
}
use of com.epam.pipeline.controller.vo.IssueVO in project cloud-pipeline by epam.
the class IssueManagerTest method testCreateIssue.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateIssue() {
when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
Issue saved = issueManager.createIssue(issueVO);
Issue loaded = issueManager.loadIssue(saved.getId());
compareIssues(saved, loaded);
ArgumentCaptor<Issue> captor = ArgumentCaptor.forClass(Issue.class);
ArgumentCaptor<String> htmlTextCaptor = ArgumentCaptor.forClass(String.class);
verify(notificationManager).notifyIssue(captor.capture(), any(), htmlTextCaptor.capture());
assertEquals(ISSUE_TEXT, captor.getValue().getText());
assertEquals(ISSUE_TEXT, htmlTextCaptor.getValue());
}
use of com.epam.pipeline.controller.vo.IssueVO in project cloud-pipeline by epam.
the class IssueApiServiceTest 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.setStatus(IssueStatus.OPEN);
return issueVO;
}
use of com.epam.pipeline.controller.vo.IssueVO in project cloud-pipeline by epam.
the class ToolDaoTest method getIssueVO.
private IssueVO getIssueVO(String name, String text, EntityVO entity) {
IssueVO issueVO = new IssueVO();
issueVO.setName(name);
issueVO.setEntity(entity);
issueVO.setText(text);
return issueVO;
}
Aggregations