use of com.epam.pipeline.manager.metadata.parser.EntityTypeField 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());
}
Aggregations