Search in sources :

Example 36 with EntityVO

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

the class IssueManagerTest method creatingIssueForNonExistentEntityShouldThrowException.

@Test(expected = IllegalArgumentException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void creatingIssueForNonExistentEntityShouldThrowException() {
    when(authManager.getAuthorizedUser()).thenReturn(AUTHOR);
    Long nonExistentEntityId = 1L;
    EntityVO nonExistentEntity = new EntityVO(nonExistentEntityId, AclClass.PIPELINE);
    IssueVO issueVO = getIssueVO(ISSUE_NAME, ISSUE_TEXT, nonExistentEntity);
    issueManager.createIssue(issueVO);
    verify(notificationManager, Mockito.never()).notifyIssue(any(), any(), any());
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) IssueVO(com.epam.pipeline.controller.vo.IssueVO) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 with EntityVO

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

the class IssueApiServiceTest method setUp.

@Before
public void setUp() {
    Folder folder = new Folder();
    folder.setName(TEST_FOLDER_NAME);
    folder.setOwner(USER_OWNER);
    folderDao.createFolder(folder);
    // Mock ACL
    AclTestDao.AclSid testUserSid = new AclTestDao.AclSid(true, USER_OWNER);
    aclTestDao.createAclSid(testUserSid);
    AclTestDao.AclClass folderAclClass = new AclTestDao.AclClass(Folder.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(folderAclClass);
    AclTestDao.AclObjectIdentity objectIdentity = new AclTestDao.AclObjectIdentity(testUserSid, folder.getId(), folderAclClass.getId(), null, true);
    aclTestDao.createObjectIdentity(objectIdentity);
    AclTestDao.AclEntry aclEntry = new AclTestDao.AclEntry(objectIdentity, 1, testUserSid, AclPermission.READ.getMask(), true);
    aclTestDao.createAclEntry(aclEntry);
    AclTestDao.AclSid noPermissionUserSid = new AclTestDao.AclSid(true, NO_PERMISSION_USER);
    aclTestDao.createAclSid(noPermissionUserSid);
    entityVO = new EntityVO(folder.getId(), AclClass.FOLDER);
    createdIssue = new Issue();
    createdIssue.setName(ISSUE_NAME);
    createdIssue.setText(ISSUE_TEXT);
    createdIssue.setAuthor(USER_OWNER);
    createdIssue.setEntity(entityVO);
    createdIssue.setStatus(IssueStatus.OPEN);
    issueDao.createIssue(createdIssue);
    createdIssueComment = new IssueComment();
    createdIssueComment.setIssueId(createdIssue.getId());
    createdIssueComment.setAuthor(USER_OWNER);
    createdIssueComment.setText(COMMENT_TEXT);
    issueCommentDao.createComment(createdIssueComment);
    AclTestDao.AclSid canReadUserSid = new AclTestDao.AclSid(true, CAN_READ_USER);
    aclTestDao.createAclSid(canReadUserSid);
    aclEntry = new AclTestDao.AclEntry(objectIdentity, 2, canReadUserSid, AclPermission.READ.getMask(), true);
    aclTestDao.createAclEntry(aclEntry);
    verify(notificationManager, Mockito.never()).notifyIssue(any(), any(), any());
    Mockito.doNothing().when(attachmentFileManager).deleteAttachments(Mockito.anyListOf(Attachment.class));
    attachment = new Attachment();
    attachment.setName("testAttachment");
    attachment.setCreatedDate(new Date());
    attachment.setPath("///");
    attachment.setOwner(TEST_USER);
    attachmentDao.createAttachment(attachment);
    Mockito.doNothing().when(attachmentFileManager).deleteAttachments(Mockito.anyListOf(Attachment.class));
}
Also used : Issue(com.epam.pipeline.entity.issue.Issue) Attachment(com.epam.pipeline.entity.issue.Attachment) Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Date(java.util.Date) EntityVO(com.epam.pipeline.controller.vo.EntityVO) IssueComment(com.epam.pipeline.entity.issue.IssueComment) AclTestDao(com.epam.pipeline.dao.util.AclTestDao) Before(org.junit.Before)

Example 38 with EntityVO

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

the class NotificationManagerTest method createIssue.

private Issue createIssue(PipelineUser author, AbstractSecuredEntity entity) {
    Issue issue = new Issue();
    issue.setName("testIssue");
    issue.setText("Notifying @TestUser1, @TestUser2, also add @admin here");
    issue.setAuthor(author.getUserName());
    issue.setEntity(new EntityVO(entity.getId(), entity.getAclClass()));
    return issue;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue)

Example 39 with EntityVO

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

the class FolderManagerTest method testListProjectsShouldReturnFolderWithIndicatorSet.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testListProjectsShouldReturnFolderWithIndicatorSet() {
    folderManager.create(folder);
    MetadataVO metadataVO = new MetadataVO();
    metadataVO.setEntity(new EntityVO(folder.getId(), AclClass.FOLDER));
    metadataVO.setData(Collections.singletonMap(PROJECT_INDICATOR_TYPE, new PipeConfValue(DEFAULT_PARAM_TYPE, PROJECT_INDICATOR_VALUE)));
    metadataManager.updateMetadataItem(metadataVO);
    List<Folder> folders = folderManager.loadAllProjects().getChildFolders();
    assertThat(folders.size(), is(1));
    assertThat(folders.get(0).getId(), is(folder.getId()));
}
Also used : MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with EntityVO

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

the class FolderManagerTest method shouldCloneFolderWithFolderMetadata.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithFolderMetadata() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    Map<String, PipeConfValue> metadata = new HashMap<>();
    metadata.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    MetadataVO metadataVO = new MetadataVO();
    metadataVO.setEntity(new EntityVO(sourceFolder.getId(), AclClass.FOLDER));
    metadataVO.setData(metadata);
    MetadataEntry expectedMetadata = metadataManager.updateMetadataItem(metadataVO);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    metadataVO.setEntity(new EntityVO(childSourceFolder.getId(), AclClass.FOLDER));
    metadataManager.updateMetadataItem(metadataVO);
    Folder destinationFolder = new Folder();
    destinationFolder.setName(TEST_NAME);
    folderManager.create(destinationFolder);
    folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
    destinationFolder = folderManager.load(folderManager.loadByNameOrId(TEST_NAME).getId());
    Folder clonedFolder = destinationFolder.getChildFolders().get(0);
    MetadataEntry clonedFolderMetadata = metadataManager.loadMetadataItem(clonedFolder.getId(), AclClass.FOLDER);
    assertEquals(clonedFolder.getId(), clonedFolderMetadata.getEntity().getEntityId());
    assertFolderMetadata(expectedMetadata, clonedFolderMetadata);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedFolderMetadata = metadataManager.loadMetadataItem(clonedChildFolder.getId(), AclClass.FOLDER);
    assertEquals(clonedChildFolder.getId(), clonedFolderMetadata.getEntity().getEntityId());
    assertFolderMetadata(expectedMetadata, clonedFolderMetadata);
}
Also used : MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) EntityVO(com.epam.pipeline.controller.vo.EntityVO) HashMap(java.util.HashMap) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

EntityVO (com.epam.pipeline.controller.vo.EntityVO)40 Transactional (org.springframework.transaction.annotation.Transactional)22 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)14 Test (org.junit.Test)14 Folder (com.epam.pipeline.entity.pipeline.Folder)13 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)12 Issue (com.epam.pipeline.entity.issue.Issue)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)8 HashMap (java.util.HashMap)5 IssueVO (com.epam.pipeline.controller.vo.IssueVO)4 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)4 Before (org.junit.Before)4 Attachment (com.epam.pipeline.entity.issue.Attachment)3 AclClass (com.epam.pipeline.entity.security.acl.AclClass)3 Date (java.util.Date)3 Map (java.util.Map)3 AfterReturning (org.aspectj.lang.annotation.AfterReturning)3 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)2 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)2 IssueComment (com.epam.pipeline.entity.issue.IssueComment)2