Search in sources :

Example 16 with Folder

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

the class MetadataEntityDaoTest method testLoadReferenceQuery.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadReferenceQuery() {
    Folder folder = createFolder();
    MetadataClass sampleClass = createMetadataClass(CLASS_NAME_1);
    MetadataClass participantClass = createMetadataClass(CLASS_NAME_2);
    MetadataClass batchClass = createMetadataClass(CLASS_NAME_3);
    Map<String, PipeConfValue> data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    MetadataEntity batch1 = createMetadataEntity(folder, batchClass, EXTERNAL_ID_1, data);
    // create a second batch to check that it isn't returned in query results
    createMetadataEntity(folder, batchClass, EXTERNAL_ID_2, data);
    data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    data.put("Batch", new PipeConfValue("Batch:ID", batch1.getExternalId()));
    MetadataEntity participant1 = createMetadataEntity(folder, participantClass, EXTERNAL_ID_1, data);
    MetadataEntity participant2 = createMetadataEntity(folder, participantClass, EXTERNAL_ID_2, data);
    data = new HashMap<>();
    data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
    data.put("Participants", new PipeConfValue("Array[Participant]", String.format("[\"%s\",\"%s\"]", participant1.getExternalId(), participant2.getExternalId())));
    MetadataEntity sample = createMetadataEntity(folder, sampleClass, EXTERNAL_ID_1, data);
    List<MetadataEntity> links = metadataEntityDao.loadAllReferences(Collections.singletonList(sample.getId()), folder.getId());
    Assert.assertEquals(new HashSet<>(Arrays.asList(batch1, participant1, participant2, sample)), new HashSet<>(links));
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with Folder

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

the class MetadataEntityDaoTest method testDeleteMetadataInFolder.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testDeleteMetadataInFolder() {
    MetadataClass metadataClass = createMetadataClass(CLASS_NAME_1);
    Map<String, PipeConfValue> data = new HashMap<>();
    Folder folder1 = createFolder();
    Folder folder2 = createFolder();
    // 2 entities in folder1
    createMetadataEntity(folder1, metadataClass, EXTERNAL_ID_1, data);
    createMetadataEntity(folder1, metadataClass, EXTERNAL_ID_2, data);
    // 1 entity in folder2
    createMetadataEntity(folder2, metadataClass, EXTERNAL_ID_2, data);
    List<MetadataEntity> folder1List = metadataEntityDao.loadMetadataEntityByClassNameAndFolderId(folder1.getId(), CLASS_NAME_1);
    Assert.assertEquals(2, folder1List.size());
    List<MetadataEntity> folder2List = metadataEntityDao.loadMetadataEntityByClassNameAndFolderId(folder2.getId(), CLASS_NAME_1);
    Assert.assertEquals(1, folder2List.size());
    metadataEntityDao.deleteMetadataFromFolder(folder1.getId());
    folder1List = metadataEntityDao.loadMetadataEntityByClassNameAndFolderId(folder1.getId(), CLASS_NAME_1);
    Assert.assertEquals(0, folder1List.size());
    folder2List = metadataEntityDao.loadMetadataEntityByClassNameAndFolderId(folder2.getId(), CLASS_NAME_1);
    Assert.assertEquals(1, folder2List.size());
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with Folder

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

the class PipelineDaoTest method assertPipelineWithParameters.

private void assertPipelineWithParameters(List<Pipeline> expected, Integer pageNum, Integer pageSize) {
    Set<Pipeline> loaded = pipelineDao.loadAllPipelinesWithParents(pageNum, pageSize);
    assertEquals(expected.size(), loaded.size());
    Map<Long, Pipeline> expectedMap = expected.stream().collect(Collectors.toMap(Pipeline::getId, Function.identity()));
    loaded.forEach(pipeline -> {
        Pipeline expectedPipeline = expectedMap.get(pipeline.getId());
        assertEquals(expectedPipeline.getName(), pipeline.getName());
        Folder expectedParent = expectedPipeline.getParent();
        Folder actualParent = pipeline.getParent();
        while (expectedParent != null) {
            assertEquals(expectedParent.getId(), actualParent.getId());
            expectedParent = expectedParent.getParent();
            actualParent = actualParent.getParent();
        }
    });
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 19 with Folder

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

the class PipelineDaoTest method shouldLoadPipelineWithFolders.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldLoadPipelineWithFolders() {
    Folder root = buildFolder(null);
    root.setParentId(0L);
    Folder folder = buildFolder(root.getId());
    folder.setParent(root);
    Folder parent = buildFolder(folder.getId());
    parent.setParent(folder);
    Pipeline pipeline = getPipeline(TEST_NAME);
    pipeline.setParentFolderId(parent.getId());
    pipelineDao.createPipeline(pipeline);
    Pipeline loaded = pipelineDao.loadPipelineWithParents(pipeline.getId());
    verifyFolderTree(loaded.getParent(), parent);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with Folder

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

the class PipelineDaoTest method testMovePipeline.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testMovePipeline() {
    Pipeline pipeline = getPipeline(TEST_NAME);
    pipelineDao.createPipeline(pipeline);
    assertNull(pipeline.getParentFolderId());
    Folder folder = getFolder();
    folderDao.createFolder(folder);
    pipeline.setParentFolderId(folder.getId());
    pipelineDao.updatePipeline(pipeline);
    assertEquals(folder.getId(), pipelineDao.loadPipeline(pipeline.getId()).getParentFolderId());
    pipeline.setParentFolderId(null);
    pipelineDao.updatePipeline(pipeline);
    assertNull(pipeline.getParentFolderId());
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) 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