Search in sources :

Example 91 with Folder

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

the class FolderManagerTest method shouldCloneFolderWithDataStorages.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithDataStorages() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    DataStorageVO dataStorageVO = constructDataStorageVO(TEST_NAME, TEST_DESCRIPTION, DataStorageType.S3, TEST_PATH, STS_DURATION, LTS_DURATION, sourceFolder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    StoragePolicy storagePolicy = dataStorageVO.getStoragePolicy();
    storagePolicy.setBackupDuration(BACKUP_DURATION);
    dataStorageVO.setStoragePolicy(storagePolicy);
    AbstractDataStorage expectedDataStorage = dataStorageManager.create(dataStorageVO, true, true, false);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    dataStorageVO.setParentFolderId(childSourceFolder.getId());
    dataStorageVO.setName(TEST_NAME_1);
    dataStorageVO.setPath(TEST_NAME_1);
    dataStorageManager.create(dataStorageVO, true, true, false);
    Folder destinationFolder = new Folder();
    destinationFolder.setName(TEST_NAME);
    folderManager.create(destinationFolder);
    folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
    destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
    destinationFolder = folderManager.load(destinationFolder.getId());
    Folder clonedFolder = destinationFolder.getChildFolders().get(0);
    AbstractDataStorage clonedDataStorage = clonedFolder.getStorages().get(0);
    clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
    assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
    assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
    assertDataStorages(expectedDataStorage, clonedDataStorage);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedDataStorage = clonedChildFolder.getStorages().get(0);
    clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
    assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
    assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
    assertDataStorages(expectedDataStorage, clonedDataStorage);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 92 with Folder

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

the class FolderManagerTest method cloneFolderWithExistentFolderNameShouldFail.

@Test(expected = IllegalStateException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void cloneFolderWithExistentFolderNameShouldFail() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    folderManager.cloneFolder(childSourceFolder.getId(), sourceFolder.getId(), CHILD_FOLDER_TO_CLONE);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 93 with Folder

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

the class FolderManagerTest method createFolderTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void createFolderTest() throws Exception {
    folderManager.create(folder);
    Folder loaded = folderManager.load(folder.getId());
    assertEquals(folder.getId(), loaded.getId());
    assertEquals(folder.getName(), loaded.getName());
    assertNull(folder.getParentId());
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 94 with Folder

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

the class FolderManagerTest method loadFolderWithPipelineAndStorage.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void loadFolderWithPipelineAndStorage() throws Exception {
    folderManager.create(folder);
    PipelineVO pipelineVO = constructPipelineVO(TEST_NAME, TEST_REPO, folder.getId());
    DataStorageVO storageVO = constructDataStorageVO(TEST_NAME, TEST_DESCRIPTION, DataStorageType.S3, TEST_PATH, STS_DURATION, LTS_DURATION, folder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    Pipeline pipeline = pipelineManager.create(pipelineVO);
    AbstractDataStorage storage = dataStorageManager.create(storageVO, false, false, false);
    Folder loaded = folderManager.load(folder.getId());
    Pipeline loadedPipe = loaded.getPipelines().get(0);
    assertNotNull(loadedPipe);
    assertEquals(pipeline.getId(), loadedPipe.getId());
    assertEquals(pipeline.getName(), loadedPipe.getName());
    assertEquals(pipeline.getParentFolderId(), loadedPipe.getParentFolderId());
    AbstractDataStorage loadedStorage = loaded.getStorages().get(0);
    assertNotNull(loadedStorage);
    assertEquals(storage.getId(), loadedStorage.getId());
    assertEquals(storage.getName(), loadedStorage.getName());
    assertEquals(storage.getParentFolderId(), loadedStorage.getParentFolderId());
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) Folder(com.epam.pipeline.entity.pipeline.Folder) ObjectCreatorUtils.constructPipelineVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructPipelineVO) PipelineVO(com.epam.pipeline.controller.vo.PipelineVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 95 with Folder

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

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