use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method createFolder.
private Folder createFolder(Long parentId) {
Folder folder = new Folder();
folder.setName(TEST_NAME);
folder.setOwner(TEST_USER);
folder.setParentId(parentId);
folderDao.createFolder(folder);
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method testLoadReferenceQueryWithParticipantsOnly.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadReferenceQueryWithParticipantsOnly() {
Folder folder = createFolder();
MetadataClass participantClass = createMetadataClass(CLASS_NAME_2);
MetadataClass sampleClass = createMetadataClass(CLASS_NAME_1);
Map<String, PipeConfValue> data = new HashMap<>();
data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
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())));
createMetadataEntity(folder, sampleClass, EXTERNAL_ID_1, data);
List<MetadataEntity> links = metadataEntityDao.loadAllReferences(Arrays.asList(participant1.getId(), participant2.getId()), folder.getId());
Assert.assertEquals(new HashSet<>(Arrays.asList(participant1, participant2)), new HashSet<>(links));
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method testGetKeys.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testGetKeys() {
MetadataClass metadataClass = createMetadataClass(CLASS_NAME_1);
Map<String, PipeConfValue> data1 = new HashMap<>();
data1.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
Folder folder = createFolder();
MetadataEntity entity = createMetadataEntity(folder, metadataClass, EXTERNAL_ID_1, data1);
Set<MetadataField> defaultKeys = new HashSet<>(MetadataEntityDao.MetadataEntityParameters.fieldNames.values());
checkGetKeys(metadataClass, folder, defaultKeys, getDataField(DATA_KEY_1));
Map<String, PipeConfValue> data2 = new HashMap<>();
data2.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
createMetadataEntity(folder, metadataClass, EXTERNAL_ID_2, data2);
checkGetKeys(metadataClass, folder, defaultKeys, getDataField(DATA_KEY_1), getDataField(DATA_KEY_2));
metadataEntityDao.deleteMetadataEntity(entity.getId());
checkGetKeys(metadataClass, folder, defaultKeys, getDataField(DATA_KEY_2));
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method testGetMetadataKeys.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testGetMetadataKeys() {
MetadataClass metadataClass1 = createMetadataClass(CLASS_NAME_1);
MetadataClass metadataClass2 = createMetadataClass(CLASS_NAME_2);
Folder parent = createFolder();
Folder child = createFolder(parent.getId());
Map<String, PipeConfValue> data1 = new HashMap<>();
data1.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
createMetadataEntity(child, metadataClass1, EXTERNAL_ID_1, data1);
Map<String, PipeConfValue> data2 = new HashMap<>();
data2.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_2, DATA_VALUE_1));
createMetadataEntity(parent, metadataClass2, EXTERNAL_ID_1, data2);
Collection<MetadataClassDescription> metadataFields = metadataEntityDao.getMetadataFields(parent.getId());
Assert.assertEquals(2, metadataFields.size());
Map<Long, MetadataClassDescription> results = metadataFields.stream().collect(Collectors.toMap(e -> e.getMetadataClass().getId(), Function.identity()));
Assert.assertEquals(Collections.singletonList(new EntityTypeField(DATA_KEY_1, DATA_TYPE_1)), results.get(metadataClass1.getId()).getFields());
Assert.assertEquals(Collections.singletonList(new EntityTypeField(DATA_KEY_2, CLASS_NAME_2)), results.get(metadataClass2.getId()).getFields());
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataEntityDaoTest method testSearchWithUnderscore.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testSearchWithUnderscore() {
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 + "1"));
Folder folder = createFolder();
// sample with "OWNER1" data, shouldn't be returned in search results
createMetadataEntity(folder, metadataClass, EXTERNAL_ID_1, data);
Map<String, PipeConfValue> dataUnderscore = new HashMap<>();
dataUnderscore.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1 + "_1"));
// sample with "OWNER_1" data, should be returned in search results
MetadataEntity sampleUnderscore = createMetadataEntity(folder, metadataClass, EXTERNAL_ID_2, dataUnderscore);
MetadataFilter filter = createFilter(folder.getId(), metadataClass.getName(), Collections.singletonList(DATA_VALUE_1 + "_"), Collections.emptyList(), null, false);
checkFilterRequest(filter, Collections.singletonList(sampleUnderscore));
}
Aggregations