Search in sources :

Example 96 with Folder

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

the class FolderManagerTest method generateFolder.

private Folder generateFolder(Long parentId) {
    Folder folder = new Folder();
    folder.setName(TEST_NAME + generateRandomString(10));
    folder.setParentId(parentId);
    folderManager.create(folder);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 97 with Folder

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

the class FolderManagerTest method shouldCloneWithRunConfiguration.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneWithRunConfiguration() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
    pipelineConfiguration.setCmdTemplate(TEST_NAME);
    RunConfigurationEntry entry = createConfigEntry(TEST_NAME, true, pipelineConfiguration);
    RunConfigurationVO runConfigurationVO = createRunConfigurationVO(TEST_NAME, TEST_DESCRIPTION, sourceFolder.getId(), Collections.singletonList(entry));
    RunConfiguration expectedRunConfiguration = runConfigurationManager.create(runConfigurationVO);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    runConfigurationVO.setParentId(childSourceFolder.getId());
    runConfigurationManager.create(runConfigurationVO);
    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);
    RunConfiguration clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedFolder.getId())).collect(Collectors.toList()).get(0);
    assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedRunConfiguration = runConfigurationManager.loadAll().stream().filter(conf -> Objects.equals(conf.getParent().getId(), clonedChildFolder.getId())).collect(Collectors.toList()).get(0);
    assertRunConfiguration(expectedRunConfiguration, clonedRunConfiguration);
}
Also used : AwsRegionVO(com.epam.pipeline.controller.vo.AwsRegionVO) MetadataVO(com.epam.pipeline.controller.vo.MetadataVO) Autowired(org.springframework.beans.factory.annotation.Autowired) ObjectCreatorUtils.constructPipelineVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructPipelineVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) Assert.assertThat(org.junit.Assert.assertThat) MockitoAnnotations(org.mockito.MockitoAnnotations) Folder(com.epam.pipeline.entity.pipeline.Folder) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Pair(org.apache.commons.lang3.tuple.Pair) MockS3Helper(com.epam.pipeline.manager.MockS3Helper) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Mockito.doReturn(org.mockito.Mockito.doReturn) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) MetadataEntityVO(com.epam.pipeline.controller.vo.metadata.MetadataEntityVO) S3StorageProvider(com.epam.pipeline.manager.datastorage.providers.aws.s3.S3StorageProvider) GitManager(com.epam.pipeline.manager.git.GitManager) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) Set(java.util.Set) Collectors(java.util.stream.Collectors) PasswordGenerator.generateRandomString(com.epam.pipeline.utils.PasswordGenerator.generateRandomString) Objects(java.util.Objects) Matchers.any(org.mockito.Matchers.any) List(java.util.List) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) ObjectCreatorUtils.createConfigEntry(com.epam.pipeline.manager.ObjectCreatorUtils.createConfigEntry) EntityVO(com.epam.pipeline.controller.vo.EntityVO) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) Mock(org.mockito.Mock) HashMap(java.util.HashMap) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) RunConfigurationVO(com.epam.pipeline.controller.vo.configuration.RunConfigurationVO) MetadataManager(com.epam.pipeline.manager.metadata.MetadataManager) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) PipelineVO(com.epam.pipeline.controller.vo.PipelineVO) Before(org.junit.Before) ObjectCreatorUtils.createRunConfigurationVO(com.epam.pipeline.manager.ObjectCreatorUtils.createRunConfigurationVO) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Test(org.junit.Test) DataStorageType(com.epam.pipeline.entity.datastorage.DataStorageType) Mockito.when(org.mockito.Mockito.when) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) Assert.assertNull(org.junit.Assert.assertNull) MetadataEntityManager(com.epam.pipeline.manager.metadata.MetadataEntityManager) AclClass(com.epam.pipeline.entity.security.acl.AclClass) RunConfigurationManager(com.epam.pipeline.manager.configuration.RunConfigurationManager) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) AwsRegionManager(com.epam.pipeline.manager.region.AwsRegionManager) Transactional(org.springframework.transaction.annotation.Transactional) RunConfigurationVO(com.epam.pipeline.controller.vo.configuration.RunConfigurationVO) ObjectCreatorUtils.createRunConfigurationVO(com.epam.pipeline.manager.ObjectCreatorUtils.createRunConfigurationVO) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 98 with Folder

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

Example 99 with Folder

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

the class PipelineRunManagerTest method testResolveProjectFiltering.

@Test
@WithMockUser(roles = "ADMIN")
public void testResolveProjectFiltering() {
    Folder project = new Folder();
    project.setId(1L);
    Folder child = new Folder();
    project.setId(2L);
    project.getChildFolders().add(child);
    Pipeline pipeline1 = new Pipeline();
    pipeline1.setId(2L);
    project.getPipelines().add(pipeline1);
    Pipeline pipeline2 = new Pipeline();
    pipeline2.setId(3L);
    child.getPipelines().add(pipeline2);
    RunConfiguration configuration1 = new RunConfiguration();
    configuration1.setId(4L);
    project.getConfigurations().add(configuration1);
    RunConfiguration configuration2 = new RunConfiguration();
    configuration2.setId(5L);
    child.getConfigurations().add(configuration2);
    when(folderManager.load(project.getId())).thenReturn(project);
    PagingRunFilterVO filterVO = new PagingRunFilterVO();
    filterVO.setProjectIds(Collections.singletonList(project.getId()));
    PipelineRunFilterVO.ProjectFilter projectFilter = pipelineRunManager.resolveProjectFiltering(filterVO);
    Assert.assertEquals(2, projectFilter.getPipelineIds().size());
    Assert.assertEquals(2, projectFilter.getConfigurationIds().size());
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) PagingRunFilterVO(com.epam.pipeline.controller.vo.PagingRunFilterVO) Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) PipelineRunFilterVO(com.epam.pipeline.controller.vo.PipelineRunFilterVO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Example 100 with Folder

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

the class PipelineWithPermissionsTest method getFolder.

private Folder getFolder(String name, String owner) {
    Folder folder = new Folder();
    folder.setName(name);
    folder.setOwner(owner);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

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