Search in sources :

Example 26 with PipeConfValue

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);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) HashMap(java.util.HashMap) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) ArrayList(java.util.ArrayList) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with PipeConfValue

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());
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with PipeConfValue

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;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry) FolderWithMetadata(com.epam.pipeline.entity.metadata.FolderWithMetadata)

Example 29 with PipeConfValue

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));
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Test(org.junit.Test)

Example 30 with PipeConfValue

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));
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Test(org.junit.Test)

Aggregations

PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)41 Test (org.junit.Test)24 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)21 HashMap (java.util.HashMap)11 Transactional (org.springframework.transaction.annotation.Transactional)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 EntityVO (com.epam.pipeline.controller.vo.EntityVO)9 Folder (com.epam.pipeline.entity.pipeline.Folder)9 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)8 FolderWithMetadata (com.epam.pipeline.entity.metadata.FolderWithMetadata)5 MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)5 PasswordGenerator.generateRandomString (com.epam.pipeline.utils.PasswordGenerator.generateRandomString)5 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)3 MessageConstants (com.epam.pipeline.common.MessageConstants)2 MessageHelper (com.epam.pipeline.common.MessageHelper)2 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)2 BaseEntity (com.epam.pipeline.entity.BaseEntity)2