Search in sources :

Example 81 with Folder

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

the class ObjectCreatorUtils method createFolder.

public static Folder createFolder(String name, Long parentId) {
    Folder folder = new Folder();
    folder.setName(name);
    folder.setParentId(parentId);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 82 with Folder

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

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

the class IssueManagerTest method setUp.

@Before
public void setUp() throws Exception {
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME);
    folder.setOwner(AUTHOR);
    folderDao.createFolder(folder);
    folderDao.loadFolder(folder.getId());
    entityVO = new EntityVO(folder.getId(), AclClass.FOLDER);
    testAttachment = new Attachment();
    testAttachment.setName("test");
    testAttachment.setPath("///");
    testAttachment.setCreatedDate(new Date());
    testAttachment.setOwner(AUTHOR);
    attachmentDao.createAttachment(testAttachment);
    Preference systemDataStorage = SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME.toPreference();
    systemDataStorage.setName(TEST_SYSTEM_DATA_STORAGE);
    when(preferenceManager.getPreference(SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME)).thenReturn(TEST_SYSTEM_DATA_STORAGE);
    when(dataStorageManager.loadByNameOrId(TEST_SYSTEM_DATA_STORAGE)).thenReturn(testSystemDataStorage);
    when(dataStorageManager.deleteDataStorageItems(any(), any(), any())).thenReturn(1);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Preference(com.epam.pipeline.entity.preference.Preference) Attachment(com.epam.pipeline.entity.issue.Attachment) Folder(com.epam.pipeline.entity.pipeline.Folder) Date(java.util.Date) Before(org.junit.Before)

Example 84 with Folder

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

the class FolderApiServiceTest method createTemplateAndGetProject.

private void createTemplateAndGetProject() {
    Folder folder = new Folder();
    folder.setName(FOLDER_NAME);
    folder.setParentId(parent.getId());
    when(folderManager.create(folder)).thenReturn(folder);
    folderApiService.create(folder);
    when(folderManager.createFromTemplate(anyObject(), anyString())).thenReturn(folder);
    folderApiService.createFromTemplate(folder, "template");
    FolderWithMetadata folderWithMetadata = new FolderWithMetadata();
    folderWithMetadata.setId(parent.getId());
    when(folderManager.getProject(anyLong(), anyObject())).thenReturn(folderWithMetadata);
    folderApiService.getProject(folderWithMetadata.getId(), AclClass.FOLDER);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata)

Example 85 with Folder

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

the class FolderApiServiceTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    ReflectionTestUtils.setField(folderApiService, "folderManager", folderManager);
    testUserSid = new AclTestDao.AclSid(true, TEST_USER);
    aclTestDao.createAclSid(testUserSid);
    testUser2Sid = new AclTestDao.AclSid(true, TEST_USER2);
    aclTestDao.createAclSid(testUser2Sid);
    AclTestDao.AclClass folderAclClass = new AclTestDao.AclClass(Folder.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(folderAclClass);
    AclTestDao.AclClass pipelineAclClass = new AclTestDao.AclClass(Pipeline.class.getCanonicalName());
    aclTestDao.createAclClassIfNotPresent(pipelineAclClass);
    // Initial creating of parent folder
    parent = new Folder();
    parent.setName("testParent");
    parent.setOwner(TEST_USER);
    folderDao.createFolder(parent);
    childFolder = new Folder();
    childFolder.setName(FOLDER_NAME);
    childFolder.setParentId(parent.getId());
    childFolder.setOwner(TEST_USER2);
    pipeline1 = constructPipeline(TEST_PIPELINE1, TEST_PIPELINE_REPO, childFolder.getId());
    pipeline1.setOwner(TEST_USER2);
    pipelineDao.createPipeline(pipeline1);
    childFolder.getPipelines().add(pipeline1);
    childFolder.setParent(parent);
    folderDao.createFolder(childFolder);
    // ACL's for Parent folder
    parentAclObjectIdentity = new AclTestDao.AclObjectIdentity(testUserSid, parent.getId(), folderAclClass.getId(), null, true);
    aclTestDao.createObjectIdentity(parentAclObjectIdentity);
    parentAclEntry = new AclTestDao.AclEntry(parentAclObjectIdentity, 1, testUserSid, AclPermission.WRITE.getMask(), true);
    aclTestDao.createAclEntry(parentAclEntry);
    pipelineAclObjectIdentity = new AclTestDao.AclObjectIdentity(testUser2Sid, pipeline1.getId(), pipelineAclClass.getId(), parentAclObjectIdentity, false);
    aclTestDao.createObjectIdentity(pipelineAclObjectIdentity);
    pipelineAclEntry = new AclTestDao.AclEntry(pipelineAclObjectIdentity, 1, testUser2Sid, AclPermission.READ.getMask(), false);
    aclTestDao.createAclEntry(pipelineAclEntry);
    childAclObjectIdentity = new AclTestDao.AclObjectIdentity(testUser2Sid, childFolder.getId(), folderAclClass.getId(), parentAclObjectIdentity, true);
    aclTestDao.createObjectIdentity(childAclObjectIdentity);
    childAclEntry = new AclTestDao.AclEntry(childAclObjectIdentity, 1, testUser2Sid, AclPermission.WRITE.getMask(), true);
    aclTestDao.createAclEntry(childAclEntry);
    // deny write for child folder fro TEST_USER
    AclTestDao.AclEntry denyChildAclEntry = new AclTestDao.AclEntry(childAclObjectIdentity, 2, testUserSid, AclPermission.NO_WRITE.getMask(), true);
    aclTestDao.createAclEntry(denyChildAclEntry);
}
Also used : AclTestDao(com.epam.pipeline.dao.util.AclTestDao) Folder(com.epam.pipeline.entity.pipeline.Folder) AclClass(com.epam.pipeline.entity.security.acl.AclClass) ObjectCreatorUtils.constructPipeline(com.epam.pipeline.manager.ObjectCreatorUtils.constructPipeline) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Before(org.junit.Before)

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