Search in sources :

Example 86 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderApiServiceTest method testCreateFolderByNotAdminOrFolderManagerAndWrite.

@Test(expected = AccessDeniedException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@WithMockUser(username = TEST_USER2)
public void testCreateFolderByNotAdminOrFolderManagerAndWrite() {
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME);
    folder.setParentId(parent.getId());
    when(folderManager.create(folder)).thenReturn(folder);
    folderApiService.create(folder);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 87 with Folder

use of com.epam.pipeline.entity.pipeline.Folder 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 88 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderManagerGetProjectTest method getProjectShouldWorkWithFolderAsInputEntity.

@Test
public void getProjectShouldWorkWithFolderAsInputEntity() {
    Mockito.when(entityManager.load(Matchers.any(AclClass.class), Matchers.any(Long.class))).thenReturn(folder3);
    Folder actualFolder = folderManager.getProject(folder3.getId(), AclClass.FOLDER);
    assertFolders(folder2, actualFolder);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 89 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderManagerGetProjectTest method getProjectShouldWorkWithPipelineAsInputEntity.

@Test
public void getProjectShouldWorkWithPipelineAsInputEntity() {
    Pipeline pipeline = new Pipeline();
    pipeline.setId(1L);
    pipeline.setParent(folder3);
    Mockito.when(entityManager.load(Matchers.any(AclClass.class), Matchers.any(Long.class))).thenReturn(pipeline);
    Folder actualFolder = folderManager.getProject(pipeline.getId(), AclClass.PIPELINE);
    assertFolders(folder2, actualFolder);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 90 with Folder

use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.

the class FolderManagerGetProjectTest method getProjectShouldWorkWithConfigurationAsInputEntity.

@Test
public void getProjectShouldWorkWithConfigurationAsInputEntity() {
    RunConfiguration configuration = new RunConfiguration();
    configuration.setId(1L);
    configuration.setParent(folder3);
    Mockito.when(entityManager.load(Matchers.any(AclClass.class), Matchers.any(Long.class))).thenReturn(configuration);
    Folder actualFolder = folderManager.getProject(configuration.getId(), AclClass.CONFIGURATION);
    assertFolders(folder2, actualFolder);
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Aggregations

Folder (com.epam.pipeline.entity.pipeline.Folder)102 Transactional (org.springframework.transaction.annotation.Transactional)53 Test (org.junit.Test)52 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)48 EntityVO (com.epam.pipeline.controller.vo.EntityVO)14 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)14 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)14 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)13 RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)11 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)10 AclClass (com.epam.pipeline.entity.security.acl.AclClass)10 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Propagation (org.springframework.transaction.annotation.Propagation)8 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)7 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)6 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)4 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)4 Collectors (java.util.stream.Collectors)4