Search in sources :

Example 21 with MetadataClass

use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.

the class FirecloudRunner method validateRootEntityType.

private void validateRootEntityType(Long rootEntityClassId) {
    Assert.notNull(rootEntityClassId, "Root entity class ID is required for creating new configuration.");
    MetadataClass rootEntityClass = metadataEntityManager.loadClass(rootEntityClassId);
    Assert.notNull(rootEntityClass.getFireCloudClassName(), String.format("Firecloud type must be provider for entity type %s.", rootEntityClass.getName()));
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass)

Example 22 with MetadataClass

use of com.epam.pipeline.entity.metadata.MetadataClass 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 23 with MetadataClass

use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.

the class MetadataEntityConverterTest method getMetadataClass.

private static MetadataClass getMetadataClass(String name, FireCloudClass type) {
    MetadataClass entityClass = new MetadataClass();
    entityClass.setName(name);
    entityClass.setFireCloudClassName(type);
    return entityClass;
}
Also used : MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass)

Example 24 with MetadataClass

use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.

the class MetadataWriterTest method entity.

private MetadataEntity entity(final String entityClass, final String id, final Map<String, PipeConfValue> data) {
    final MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setExternalId(id);
    metadataEntity.setData(data);
    final MetadataClass metadataClass = new MetadataClass();
    metadataClass.setName(entityClass);
    metadataEntity.setClassEntity(metadataClass);
    return metadataEntity;
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass)

Example 25 with MetadataClass

use of com.epam.pipeline.entity.metadata.MetadataClass in project cloud-pipeline by epam.

the class MetadataEntityMapperTest method shouldMapMetadataEntity.

@Test
void shouldMapMetadataEntity() throws IOException {
    MetadataEntityMapper mapper = new MetadataEntityMapper();
    MetadataClass metadataClass = new MetadataClass(1L, "Sample");
    MetadataEntity metadataEntity = new MetadataEntity();
    metadataEntity.setClassEntity(metadataClass);
    metadataEntity.setId(1L);
    metadataEntity.setExternalId("external");
    metadataEntity.setParent(new Folder(1L));
    metadataEntity.setName(TEST_NAME);
    metadataEntity.setData(Collections.singletonMap(TEST_KEY, new PipeConfValue("string", TEST_VALUE)));
    EntityContainer<MetadataEntity> container = EntityContainer.<MetadataEntity>builder().entity(metadataEntity).permissions(PERMISSIONS_CONTAINER).build();
    XContentBuilder contentBuilder = mapper.map(container);
    verifyMetadataEntity(metadataEntity, EXPECTED_METADATA, contentBuilder);
    verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) MapperVerificationUtils.verifyMetadataEntity(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyMetadataEntity) MetadataClass(com.epam.pipeline.entity.metadata.MetadataClass) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) Folder(com.epam.pipeline.entity.pipeline.Folder) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataClass (com.epam.pipeline.entity.metadata.MetadataClass)25 Folder (com.epam.pipeline.entity.pipeline.Folder)11 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)10 Transactional (org.springframework.transaction.annotation.Transactional)10 Test (org.junit.Test)7 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)6 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)5 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)3 MetadataReadingException (com.epam.pipeline.exception.MetadataReadingException)3 IOException (java.io.IOException)3 com.epam.pipeline.manager.metadata.parser (com.epam.pipeline.manager.metadata.parser)2 FolderManager (com.epam.pipeline.manager.pipeline.FolderManager)2 AuthManager (com.epam.pipeline.manager.security.AuthManager)2 MetadataParsingUtils (com.epam.pipeline.manager.utils.MetadataParsingUtils)2 InputStream (java.io.InputStream)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Test (org.junit.jupiter.api.Test)2