Search in sources :

Example 6 with MetadataClass

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

the class ConfigurationRunner method getIdsToProcess.

private List<Long> getIdsToProcess(RunConfigurationWithEntitiesVO runConfiguration) {
    if (CollectionUtils.isNotEmpty(runConfiguration.getEntitiesIds())) {
        return runConfiguration.getEntitiesIds();
    }
    if (StringUtils.hasText(runConfiguration.getMetadataClass())) {
        Folder folder = folderManager.load(runConfiguration.getFolderId());
        Assert.notNull(folder, "Project is required to launch whole class processing.");
        MetadataClass metadataClass = metadataEntityManager.loadClass(runConfiguration.getMetadataClass());
        return metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(folder.getId(), metadataClass.getName()).stream().map(BaseEntity::getId).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 7 with MetadataClass

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

the class MetadataClassDaoTest method testCRUDMetadataClass.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUDMetadataClass() {
    MetadataClass metadataClass = new MetadataClass();
    metadataClass.setId(CLASS_ID_1);
    metadataClass.setName(CLASS_NAME_1);
    metadataClassDao.createMetadataClass(metadataClass);
    List<MetadataClass> expectedResult = Collections.singletonList(metadataClass);
    Assert.assertEquals(expectedResult, metadataClassDao.loadAllMetadataClasses());
    metadataClass.setFireCloudClassName(FireCloudClass.SAMPLE);
    metadataClassDao.updateMetadataClass(metadataClass);
    expectedResult = Collections.singletonList(metadataClass);
    Assert.assertEquals(expectedResult, metadataClassDao.loadAllMetadataClasses());
    metadataClassDao.deleteMetadataClass(metadataClass.getId());
    Assert.assertEquals(Collections.emptyList(), metadataClassDao.loadAllMetadataClasses());
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with MetadataClass

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

the class FolderDaoTest method createMetadataClass.

private MetadataClass createMetadataClass() {
    MetadataClass metadataClass = new MetadataClass();
    metadataClass.setName(CLASS_NAME_1);
    metadataClassDao.createMetadataClass(metadataClass);
    return metadataClass;
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass)

Example 9 with MetadataClass

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

the class ObjectCreatorUtils method createMetadataClass.

public static MetadataClass createMetadataClass(String name) {
    MetadataClass metadataClass = new MetadataClass();
    metadataClass.setName(name);
    return metadataClass;
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass)

Example 10 with MetadataClass

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

the class FolderEventServiceTest method shouldAddFolderEvent.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldAddFolderEvent() {
    doNothing().when(entityManager).setManagers(anyListOf(SecuredEntityManager.class));
    Folder folder2 = new Folder(2L);
    Pipeline pipeline = new Pipeline(1L);
    S3bucketDataStorage dataStorage = new S3bucketDataStorage(1L, "", "");
    RunConfiguration runConfiguration = new RunConfiguration();
    runConfiguration.setId(1L);
    MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setClassEntity(new MetadataClass(1L, METADATA_CLASS_NAME));
    metadataEntity.setId(1L);
    Folder folder1 = new Folder(1L);
    folder1.setChildFolders(Collections.singletonList(folder2));
    folder1.setPipelines(Collections.singletonList(pipeline));
    folder1.setStorages(Collections.singletonList(dataStorage));
    folder1.setConfigurations(Collections.singletonList(runConfiguration));
    folder1.setMetadata(Collections.singletonMap(METADATA_CLASS_NAME, 1));
    when(issueManager.loadIssuesForEntity(any())).thenReturn(Arrays.asList(Issue.builder().id(1L).build(), Issue.builder().id(2L).build()));
    when(pipelineRunManager.loadAllRunsByPipeline(anyLong())).thenReturn(Arrays.asList(new PipelineRun(1L, ""), new PipelineRun(2L, "")));
    when(dataStorageManager.load(1L)).thenReturn(dataStorage);
    when(folderManager.load(1L)).thenReturn(folder1);
    when(folderManager.load(2L)).thenReturn(folder2);
    when(metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(anyLong(), anyString())).thenReturn(Collections.singletonList(metadataEntity));
    doNothing().when(eventDao).insertUpdateEvent(anyString(), anyLong());
    folderEventService.updateEventsWithChildrenAndIssues(1L);
    verify(eventDao).insertUpdateEvent("folder", 1L);
    verify(eventDao).insertUpdateEvent("folder", 2L);
    verify(eventDao).insertUpdateEvent("pipeline", 1L);
    verify(eventDao).insertUpdateEvent("run", 1L);
    verify(eventDao).insertUpdateEvent("run", 2L);
    verify(eventDao).insertUpdateEvent("S3", 1L);
    verify(eventDao).insertUpdateEvent("configuration", 1L);
    verify(eventDao).insertUpdateEvent("metadata_entity", 1L);
    verify(eventDao, times(6)).insertUpdateEvent("issue", 1L);
    verify(eventDao, times(6)).insertUpdateEvent("issue", 2L);
    verifyNoMoreInteractions(eventDao);
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) SecuredEntityManager(com.epam.pipeline.manager.security.SecuredEntityManager) RunConfiguration(com.epam.pipeline.entity.configuration.RunConfiguration) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)25 Folder (com.epam.pipeline.entity.pipeline.Folder)11 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)10 Transactional (org.springframework.transaction.annotation.Transactional)10 Test (org.junit.Test)7 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)6 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)5 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)3 MetadataReadingException (com.epam.pipeline.exception.MetadataReadingException)3 IOException (java.io.IOException)3 com.epam.pipeline.manager.metadata.parser (com.epam.pipeline.manager.metadata.parser)2 FolderManager (com.epam.pipeline.manager.pipeline.FolderManager)2 AuthManager (com.epam.pipeline.manager.security.AuthManager)2 MetadataParsingUtils (com.epam.pipeline.manager.utils.MetadataParsingUtils)2 InputStream (java.io.InputStream)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Test (org.junit.jupiter.api.Test)2