Search in sources :

Example 16 with RunConfiguration

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

the class FolderDaoTest method testCreateAndLoadFolderWithConfigurations.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateAndLoadFolderWithConfigurations() {
    Folder folder = getFolder();
    AbstractDataStorage storage = addStorage(folder);
    RunConfiguration configuration = addConfiguration(folder);
    Folder loaded = folderDao.loadFolder(folder.getId());
    assertEquals(folder.getId(), loaded.getId());
    assertEquals(folder.getName(), loaded.getName());
    assertNull(folder.getParentId());
    checkStorageIsPresent(storage, loaded);
    checkConfigIsPresent(configuration, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with RunConfiguration

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

the class ObjectCreatorUtils method createConfiguration.

public static RunConfiguration createConfiguration(String name, String description, Long parentFolderId, String owner, List<AbstractRunConfigurationEntry> entries) {
    RunConfiguration configuration = new RunConfiguration();
    configuration.setName(name);
    if (parentFolderId != null) {
        configuration.setParent(new Folder(parentFolderId));
    }
    configuration.setDescription(description);
    configuration.setOwner(owner);
    configuration.setEntries(entries);
    return configuration;
}
Also used : RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 18 with RunConfiguration

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

Example 19 with RunConfiguration

use of com.epam.pipeline.entity.configuration.RunConfiguration 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 20 with RunConfiguration

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

Aggregations

RunConfiguration (com.epam.pipeline.entity.configuration.RunConfiguration)23 Folder (com.epam.pipeline.entity.pipeline.Folder)10 Transactional (org.springframework.transaction.annotation.Transactional)9 Test (org.junit.Test)8 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)7 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)6 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)6 FirecloudRunConfigurationEntry (com.epam.pipeline.entity.configuration.FirecloudRunConfigurationEntry)5 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)4 MapperVerificationUtils.verifyRunConfiguration (com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyRunConfiguration)3 AbstractRunConfigurationEntry (com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry)3 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)3 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)3 ConfigurationEntryDoc (com.epam.pipeline.elasticsearchagent.model.ConfigurationEntryDoc)2 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)2 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)2 AclClass (com.epam.pipeline.entity.security.acl.AclClass)2 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)2 Test (org.junit.jupiter.api.Test)2 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)1