use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.
the class MetadataDaoTest method testListMetadata.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testListMetadata() {
EntityVO entity1 = new EntityVO(ID_1, CLASS_1);
Map<String, PipeConfValue> data1 = new HashMap<>();
data1.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
MetadataEntry metadataToSave1 = new MetadataEntry();
metadataToSave1.setEntity(entity1);
metadataToSave1.setData(data1);
EntityVO entity2 = new EntityVO(ID_2, CLASS_2);
Map<String, PipeConfValue> data2 = new HashMap<>();
data2.put(DATA_KEY_2, new PipeConfValue(DATA_TYPE_2, DATA_VALUE_2));
MetadataEntry metadataToSave2 = new MetadataEntry();
metadataToSave2.setEntity(entity2);
metadataToSave2.setData(data2);
metadataDao.registerMetadataItem(metadataToSave1);
metadataDao.registerMetadataItem(metadataToSave2);
List<EntityVO> entities = new ArrayList<>();
entities.add(entity1);
entities.add(entity2);
List<MetadataEntry> metadataEntries = new ArrayList<>();
metadataEntries.add(metadataToSave1);
metadataEntries.add(metadataToSave2);
List<MetadataEntry> createdMetadata = metadataDao.loadMetadataItems(entities);
Assert.assertEquals(metadataEntries, createdMetadata);
metadataDao.deleteMetadataItem(entity1);
metadataDao.deleteMetadataItem(entity2);
createdMetadata = metadataDao.loadMetadataItems(entities);
Assert.assertNull(createdMetadata);
}
use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.
the class FolderDaoTest method testCreateAndLoadFolderWithMetadata.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCreateAndLoadFolderWithMetadata() {
Folder folder = getFolder();
// create
folderDao.createFolder(folder);
Map<String, Integer> metadata = new HashMap<>();
metadata.put(CLASS_NAME_1, 1);
folder.setMetadata(metadata);
// add metadata
MetadataEntity metadataEntity = new MetadataEntity();
metadataEntity.setName(TEST_ENTITY_NAME_1);
MetadataClass metadataClass = createMetadataClass();
metadataEntity.setClassEntity(metadataClass);
metadataEntity.setParent(folder);
Map<String, PipeConfValue> data = new HashMap<>();
data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
metadataEntity.setData(data);
metadataEntityDao.createMetadataEntity(metadataEntity);
Folder loaded = folderDao.loadFolder(folder.getId());
assertEquals(folder.getId(), loaded.getId());
assertEquals(folder.getName(), loaded.getName());
assertEquals(folder.getMetadata(), loaded.getMetadata());
assertNull(folder.getParentId());
Map<String, Integer> loadedMetadata = loaded.getMetadata();
assertTrue(!loadedMetadata.isEmpty() && loadedMetadata.size() == 1);
assertEquals(metadataEntity.getClassEntity().getName(), loadedMetadata.keySet().toArray()[0]);
assertEquals(1, loadedMetadata.get(CLASS_NAME_1).intValue());
}
use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.
the class FolderDaoTest method createObjectMetadata.
private List<FolderWithMetadata> createObjectMetadata(List<Folder> folders) {
Map<String, PipeConfValue> data = new HashMap<>();
data.put(DATA_KEY_1, new PipeConfValue(DATA_TYPE_1, DATA_VALUE_1));
MetadataEntry metadataToSave = new MetadataEntry();
List<FolderWithMetadata> foldersWithMetadata = new ArrayList<>();
folders.forEach(folder -> {
metadataToSave.setEntity(new EntityVO(folder.getId(), AclClass.FOLDER));
metadataToSave.setData(data);
metadataDao.registerMetadataItem(metadataToSave);
FolderWithMetadata folderWithMetadata = convertToFolderWithMetadata(folder);
folderWithMetadata.setData(data);
foldersWithMetadata.add(folderWithMetadata);
});
return foldersWithMetadata;
}
use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.
the class MetadataEntityConverterTest method shouldFailIfPairWithoutParticipantAttribute.
@Test(expected = IllegalArgumentException.class)
public void shouldFailIfPairWithoutParticipantAttribute() {
Map<String, PipeConfValue> pairData = new HashMap<>();
pairData.put(CASE_SAMPLE_ARGUMENT, new PipeConfValue(SAMPLE_ATTRIBUTE_TYPE, SAMPLE_ENTITY_ID2));
pairData.put(CONTROL_SAMPLE_ARGUMENT, new PipeConfValue(SAMPLE_ATTRIBUTE_TYPE, SAMPLE_ENTITY_ID1));
MetadataEntity pair = getEntity(pairClass, PAIR_ENTITY_ID1, pairData);
MetadataEntityConverter.convert(Collections.singletonList(pair));
}
use of com.epam.pipeline.entity.metadata.PipeConfValue in project cloud-pipeline by epam.
the class MetadataEntityConverterTest method shouldFailIfPairWithoutCaseSampleAttribute.
@Test(expected = IllegalArgumentException.class)
public void shouldFailIfPairWithoutCaseSampleAttribute() {
Map<String, PipeConfValue> pairData = new HashMap<>();
pairData.put(PARTICIPANT_TYPE_NAME, new PipeConfValue(PARTICIPANT_TYPE_NAME, PARTICIPANT_ENTITY_ID1));
pairData.put(CONTROL_SAMPLE_ARGUMENT, new PipeConfValue(SAMPLE_ATTRIBUTE_TYPE, SAMPLE_ENTITY_ID1));
MetadataEntity pair = getEntity(pairClass, PAIR_ENTITY_ID1, pairData);
MetadataEntityConverter.convert(Collections.singletonList(pair));
}
Aggregations