Search in sources :

Example 21 with Folder

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

the class PipelineDaoTest method getFolder.

private Folder getFolder() {
    Folder folder = new Folder();
    folder.setName(TEST_NAME);
    folder.setOwner(TEST_USER);
    return folder;
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 22 with Folder

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

the class DataStorageManagerTest method updateDataStorageTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void updateDataStorageTest() throws Exception {
    Folder folder = new Folder();
    folder.setName("testfolder");
    folderManager.create(folder);
    DataStorageVO storageVO = ObjectCreatorUtils.constructDataStorageVO(NAME, DESCRIPTION, DataStorageType.S3, PATH, STS_DURATION, LTS_DURATION, folder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    AbstractDataStorage saved = storageManager.create(storageVO, false, false, false);
    Folder newFolder = new Folder();
    newFolder.setName("newtestfolder");
    folderManager.create(newFolder);
    // test that we can change parent folder for storage
    storageVO.setId(saved.getId());
    storageVO.setParentFolderId(newFolder.getId());
    storageManager.update(storageVO);
    AbstractDataStorage loaded = storageManager.load(saved.getId());
    assertDataStorageAccordingToUpdateStorageVO(storageVO, loaded);
    // test that we can change description for storage
    storageVO.setDescription(CHANGED);
    storageManager.update(storageVO);
    loaded = storageManager.load(saved.getId());
    assertDataStorageAccordingToUpdateStorageVO(storageVO, loaded);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with Folder

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

Example 24 with Folder

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

the class MetadataUploadManagerTest method prepareRequiredEntities.

private Folder prepareRequiredEntities() {
    when(authManager.getAuthorizedUser()).thenReturn("user");
    Folder folder = createFolder();
    MetadataClass participantClass = entityManager.createMetadataClass(MetadataFileBuilder.PARTICIPANT_CLASS_NAME);
    MetadataClass pairClass = entityManager.createMetadataClass(MetadataFileBuilder.PAIR_CLASS_NAME);
    entityManager.updateMetadataEntity(createEntityVO(folder.getId(), participantClass.getId(), MetadataFileBuilder.PARTICIPANT1_ID));
    entityManager.updateMetadataEntity(createEntityVO(folder.getId(), participantClass.getId(), MetadataFileBuilder.PARTICIPANT2_ID));
    entityManager.updateMetadataEntity(createEntityVO(folder.getId(), pairClass.getId(), MetadataFileBuilder.PAIR1_ID));
    entityManager.updateMetadataEntity(createEntityVO(folder.getId(), pairClass.getId(), MetadataFileBuilder.PAIR2_ID));
    return folder;
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) Folder(com.epam.pipeline.entity.pipeline.Folder)

Example 25 with Folder

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

the class MetadataUploadManagerTest method uploadingMetadataWithWrongFieldTypeThrowsException.

@Test(expected = MetadataReadingException.class)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void uploadingMetadataWithWrongFieldTypeThrowsException() throws IOException {
    Folder folder = prepareRequiredEntities();
    entityManager.createMetadataClass(MetadataFileBuilder.SAMPLE_CLASS_NAME);
    uploadMetadata(folder, Arrays.asList(HEADER1, LINE1));
    uploadMetadata(folder, Arrays.asList(HEADER2, LINE2));
    String headerWithWrongFieldType = "Sample:ID${d}SampleName${d}participant${d}fast_dir:Path\n";
    uploadMetadata(folder, Arrays.asList(headerWithWrongFieldType, LINE3));
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) 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