Search in sources :

Example 1 with EntityTypeField

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());
}
Also used : BaseEntity(com.epam.pipeline.entity.BaseEntity) EntityTypeField(com.epam.pipeline.manager.metadata.parser.EntityTypeField) java.util(java.util) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Folder(com.epam.pipeline.entity.pipeline.Folder) Stream(java.util.stream.Stream) Propagation(org.springframework.transaction.annotation.Propagation) com.epam.pipeline.entity.metadata(com.epam.pipeline.entity.metadata) ObjectCreatorUtils(com.epam.pipeline.manager.ObjectCreatorUtils) FolderDao(com.epam.pipeline.dao.pipeline.FolderDao) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) EntityTypeField(com.epam.pipeline.manager.metadata.parser.EntityTypeField) Folder(com.epam.pipeline.entity.pipeline.Folder) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 FolderDao (com.epam.pipeline.dao.pipeline.FolderDao)1 BaseEntity (com.epam.pipeline.entity.BaseEntity)1 com.epam.pipeline.entity.metadata (com.epam.pipeline.entity.metadata)1 Folder (com.epam.pipeline.entity.pipeline.Folder)1 ObjectCreatorUtils (com.epam.pipeline.manager.ObjectCreatorUtils)1 EntityTypeField (com.epam.pipeline.manager.metadata.parser.EntityTypeField)1 java.util (java.util)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Propagation (org.springframework.transaction.annotation.Propagation)1 Transactional (org.springframework.transaction.annotation.Transactional)1