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));
}
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());
}
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();
}
});
}
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);
}
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());
}
Aggregations