use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class SecuredEntityDeletionAspect method deleteRole.
@AfterReturning(pointcut = "execution(* *.deleteRole(..))", returning = ROLE)
@Transactional(propagation = Propagation.REQUIRED)
public void deleteRole(JoinPoint joinPoint, Role role) {
LOGGER.debug("Deleting metadata for Object {} {}", role.getName(), AclClass.ROLE);
metadataManager.deleteMetadata(new EntityVO(role.getId(), AclClass.ROLE));
}
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()));
}
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);
}
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;
}
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));
}
Aggregations