Search in sources :

Example 6 with IssueVO

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

the class ToolDaoTest method testLoadToolsWithIssuesCount.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadToolsWithIssuesCount() {
    // create tool
    Tool tool = generateTool();
    tool.setRegistryId(firstRegistry.getId());
    tool.setToolGroupId(library1.getId());
    toolDao.createTool(tool);
    // create issues
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    EntityVO entityVO = new EntityVO(tool.getId(), AclClass.TOOL);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    issueManager.createIssue(issueVO);
    verify(notificationManager).notifyIssue(any(), any(), any());
    issueVO.setName(ISSUE_NAME2);
    issueManager.createIssue(issueVO);
    List<ToolWithIssuesCount> loaded = toolDao.loadToolsWithIssuesCountByGroup(library1.getId());
    Assert.assertEquals(1, loaded.size());
    Assert.assertEquals(2, loaded.get(0).getIssuesCount());
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) ToolWithIssuesCount(com.epam.pipeline.entity.pipeline.ToolWithIssuesCount) IssueVO(com.epam.pipeline.controller.vo.IssueVO) Tool(com.epam.pipeline.entity.pipeline.Tool) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with IssueVO

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

the class IssueManagerTest method registerIssue.

private Issue registerIssue() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    return issueManager.createIssue(issueVO);
}
Also used : IssueVO(com.epam.pipeline.controller.vo.IssueVO)

Example 8 with IssueVO

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

the class IssueManagerTest method testLoadAndDeleteIssuesForEntity.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadAndDeleteIssuesForEntity() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    issueVO.setAttachments(Collections.singletonList(testAttachment));
    Issue issue = issueManager.createIssue(issueVO);
    Issue issue2 = issueManager.createIssue(getIssueVO(ISSUE_NAME2, ISSUE_TEXT, entityVO));
    // load
    List<Issue> actualIssues = issueManager.loadIssuesForEntity(entityVO);
    assertEquals(2, actualIssues.size());
    List<Issue> expectedIssues = Stream.of(issue, issue2).collect(Collectors.toList());
    Map<Long, Issue> expectedMap = expectedIssues.stream().collect(Collectors.toMap(Issue::getId, Function.identity()));
    actualIssues.forEach(i -> compareIssues(expectedMap.get(i.getId()), i));
    // delete
    issueManager.deleteIssuesForEntity(entityVO);
    actualIssues = issueManager.loadIssuesForEntity(entityVO);
    assertEquals(0, actualIssues.size());
}
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 9 with IssueVO

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

the class IssueManagerTest method testDeleteIssuesWhenEntityWasDeleted.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteIssuesWhenEntityWasDeleted() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME_2);
    folder.setOwner(AUTHOR);
    folderDao.createFolder(folder);
    EntityVO entityVO = new EntityVO(folder.getId(), AclClass.FOLDER);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO);
    issueManager.createIssue(issueVO);
    folderManager.delete(folder.getId());
    List<Issue> issues = issueManager.loadIssuesForEntity(entityVO);
    assertTrue(CollectionUtils.isEmpty(issues));
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) Folder(com.epam.pipeline.entity.pipeline.Folder) IssueVO(com.epam.pipeline.controller.vo.IssueVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with IssueVO

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

the class IssueManagerTest method creatingIssueWithEmptyNameShouldThrowException.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void creatingIssueWithEmptyNameShouldThrowException() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    IssueVO issueVO = getIssueVO("", ISSUE_TEXT, entityVO);
    issueManager.createIssue(issueVO);
}
Also used : 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