use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method testSearch.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testSearch() {
MetadataClass metadataClass1 = createMetadataClass(CLASS_NAME_1);
MetadataClass metadataClass2 = createMetadataClass(CLASS_NAME_2);
Map<String, PipeConfValue> data1 = new HashMap<>();
data1.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
Folder folder1 = createFolder();
Folder folder2 = createFolder();
MetadataEntity folder1Sample1 = createMetadataEntity(folder1, metadataClass1, EXTERNAL_ID_1, data1);
Map<String, PipeConfValue> data2 = new HashMap<>();
data2.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_2));
data2.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
MetadataEntity folder1Sample2 = createMetadataEntity(folder1, metadataClass1, EXTERNAL_ID_2, data2);
// these objects are created just to check that requests doesn't return data from another folder/class
createMetadataEntity(folder1, metadataClass2, EXTERNAL_ID_1, data2);
createMetadataEntity(folder2, metadataClass1, EXTERNAL_ID_1, data1);
List<MetadataEntity> expectedSamples12 = Arrays.asList(folder1Sample1, folder1Sample2);
List<MetadataEntity> expectedSamples21 = Arrays.asList(folder1Sample2, folder1Sample1);
// test request with only folder and class
MetadataFilter filterEmpty = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false);
checkFilterRequest(filterEmpty, expectedSamples12);
MetadataFilter filterEmptyRecursive = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), true);
checkFilterRequest(filterEmptyRecursive, expectedSamples21);
// sorting
List<MetadataFilter.OrderBy> tagSortingAsc = Arrays.asList(new MetadataFilter.OrderBy(DATA_KEY_1, false), new MetadataFilter.OrderBy("id", false));
MetadataFilter order = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.emptyList(), tagSortingAsc, false);
checkFilterRequest(order, expectedSamples21);
MetadataFilter orderRecursive = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.emptyList(), tagSortingAsc, true);
checkFilterRequest(orderRecursive, expectedSamples21);
MetadataFilter orderDesc = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.emptyList(), Arrays.asList(new MetadataFilter.OrderBy(DATA_KEY_1, true), new MetadataFilter.OrderBy("id", false)), false);
checkFilterRequest(orderDesc, expectedSamples12);
// filter by field
MetadataFilter filterByField = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.singletonList(new MetadataFilter.FilterQuery("externalId", EXTERNAL_ID_2)), Collections.emptyList(), false);
checkFilterRequest(filterByField, Collections.singletonList(folder1Sample2));
// filter by json
MetadataFilter filterByValue = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.singletonList(new MetadataFilter.FilterQuery(DATA_KEY_1, DATA_VALUE_2)), Collections.emptyList(), false);
checkFilterRequest(filterByValue, Collections.singletonList(folder1Sample2));
MetadataFilter filterByValueRec = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.singletonList(new MetadataFilter.FilterQuery(DATA_KEY_1, DATA_VALUE_1)), Collections.emptyList(), true);
checkFilterRequest(filterByValueRec, Collections.singletonList(folder1Sample1));
MetadataFilter filterByValueWrongValue = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.singletonList(new MetadataFilter.FilterQuery(DATA_KEY_1, TEST_USER)), Collections.emptyList(), true);
checkFilterRequest(filterByValueWrongValue, Collections.emptyList());
MetadataFilter filterByValueWrongKey = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.singletonList(new MetadataFilter.FilterQuery(DATA_VALUE_2, DATA_VALUE_2)), Collections.emptyList(), true);
checkFilterRequest(filterByValueWrongKey, Collections.emptyList());
// search
MetadataFilter searchBothMatch = createFilter(folder1.getId(), metadataClass1.getName(), Collections.singletonList("ner"), Collections.emptyList(), Collections.singletonList(new MetadataFilter.OrderBy("id", false)), true);
checkFilterRequest(searchBothMatch, expectedSamples12);
MetadataFilter searchOneMatch = createFilter(folder1.getId(), metadataClass1.getName(), Collections.singletonList("MIN"), Collections.emptyList(), Collections.emptyList(), true);
checkFilterRequest(searchOneMatch, Collections.singletonList(folder1Sample2));
MetadataFilter searchNoneMatch = createFilter(folder1.getId(), metadataClass1.getName(), Collections.singletonList(DATA_KEY_1), Collections.emptyList(), Collections.emptyList(), true);
checkFilterRequest(searchNoneMatch, Collections.emptyList());
// search by external ID:
MetadataFilter searchByExternalId = createFilter(folder1.getId(), metadataClass1.getName(), Collections.emptyList(), Collections.emptyList(), Collections.singletonList(new MetadataFilter.OrderBy("id", false)), false, Collections.singletonList(EXTERNAL_ID_1));
checkFilterRequest(searchByExternalId, Collections.singletonList(folder1Sample1));
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method testBatchQueries.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testBatchQueries() {
Folder folder = createFolder();
MetadataClass metadataClass = createMetadataClass(CLASS_NAME_1);
Map<String, PipeConfValue> data = new HashMap<>();
data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
MetadataEntity entity1 = ObjectCreatorUtils.createMetadataEntity(folder, metadataClass, TEST_ENTITY_NAME_1, EXTERNAL_ID_1, data);
MetadataEntity entity2 = ObjectCreatorUtils.createMetadataEntity(folder, metadataClass, TEST_ENTITY_NAME_1, EXTERNAL_ID_2, data);
Collection<MetadataEntity> result = metadataEntityDao.batchInsert(Arrays.asList(entity1, entity2));
Assert.assertTrue(result.stream().allMatch(e -> e.getId() != null));
data.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_2, DATA_VALUE_2));
entity1.setData(data);
entity2.setData(data);
metadataEntityDao.batchUpdate(Arrays.asList(entity1, entity2));
List<MetadataEntity> loaded = metadataEntityDao.loadMetadataEntityByClassNameAndFolderId(folder.getId(), metadataClass.getName());
Assert.assertTrue(loaded.stream().allMatch(e -> e.getData().equals(data)));
Set<Long> entitiesToDelete = Stream.of(entity1.getId(), entity2.getId()).collect(Collectors.toSet());
metadataEntityDao.deleteMetadataEntities(entitiesToDelete);
Assert.assertEquals(0, metadataEntityDao.loadAllMetadataEntities().stream().filter(entity -> entitiesToDelete.contains(entity.getId())).count());
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class PipelineDaoTest method buildFolder.
private Folder buildFolder(final Long parentId) {
Folder folder = getFolder();
folder.setParentId(parentId);
folderDao.createFolder(folder);
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class PipelineDaoTest method testLoadAllPipelinesWithFolderTree.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadAllPipelinesWithFolderTree() {
Pipeline rootPipeline = getPipeline("ROOT_PIPELINE");
pipelineDao.createPipeline(rootPipeline);
assertNull(rootPipeline.getParentFolderId());
Folder rootFolder = getFolder();
folderDao.createFolder(rootFolder);
Pipeline pipeline1 = getPipeline("PIPELINE1");
pipeline1.setParentFolderId(rootFolder.getId());
pipeline1.setParent(rootFolder);
pipelineDao.createPipeline(pipeline1);
Folder doNotConsider = new Folder();
doNotConsider.setName("NOT_CONSIDER");
doNotConsider.setOwner(TEST_USER);
folderDao.createFolder(doNotConsider);
Folder folder1 = getFolder();
folder1.setParentId(rootFolder.getId());
folder1.setParent(rootFolder);
folderDao.createFolder(folder1);
Folder folder2 = getFolder();
folder2.setParentId(folder1.getId());
folder2.setParent(folder1);
folderDao.createFolder(folder2);
Folder folder3 = getFolder();
folder3.setParentId(folder2.getId());
folder3.setParent(folder2);
folderDao.createFolder(folder3);
Pipeline pipeline2 = getPipeline("PIPELINE2");
pipeline2.setParentFolderId(folder3.getId());
pipeline2.setParent(folder3);
pipelineDao.createPipeline(pipeline2);
List<Pipeline> expected = Stream.of(rootPipeline, pipeline1, pipeline2).collect(Collectors.toList());
assertPipelineWithParameters(expected, null, null);
assertPipelineWithParameters(expected, 1, 3);
expected = Stream.of(rootPipeline, pipeline1).collect(Collectors.toList());
assertPipelineWithParameters(expected, 1, 2);
expected = Stream.of(pipeline2).collect(Collectors.toList());
assertPipelineWithParameters(expected, 2, 2);
}
use of com.epam.pipeline.entity.pipeline.Folder 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;
}
Aggregations