Search in sources :

Example 6 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class RestUtilsTest method convertV2toV1.

private List<HierarchicalTypeDefinition<ClassType>> convertV2toV1(List<AtlasEntityDef> toConvert) throws AtlasBaseException {
    AtlasTypeRegistry reg = createRegistry(toConvert);
    List<HierarchicalTypeDefinition<ClassType>> result = new ArrayList<>(toConvert.size());
    for (int i = 0; i < toConvert.size(); i++) {
        AtlasEntityDef entityDef = toConvert.get(i);
        AtlasEntityType entity = reg.getEntityTypeByName(entityDef.getName());
        HierarchicalTypeDefinition<ClassType> converted = TypeConverterUtil.toTypesDef(entity, reg).classTypesAsJavaList().get(0);
        result.add(converted);
    }
    return result;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) ArrayList(java.util.ArrayList) ClassType(org.apache.atlas.typesystem.types.ClassType) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Example 7 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class TestAtlasClassification method testClassificationSerDeWithSuperType.

@Test
public void testClassificationSerDeWithSuperType() throws AtlasBaseException {
    AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperType();
    AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
    AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classificationDef.getName());
    assertNotNull(classificationType);
    AtlasClassification ent1 = classificationType.createDefaultValue();
    String jsonString = AtlasType.toJson(ent1);
    AtlasClassification ent2 = AtlasType.fromJson(jsonString, AtlasClassification.class);
    classificationType.normalizeAttributeValues(ent2);
    assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasClassification with superType");
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasClassificationType(org.apache.atlas.type.AtlasClassificationType) Test(org.testng.annotations.Test)

Example 8 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class TestAtlasClassification method testClassificationSerDeWithSuperTypes.

@Test
public void testClassificationSerDeWithSuperTypes() throws AtlasBaseException {
    AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes();
    AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
    AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classificationDef.getName());
    assertNotNull(classificationType);
    AtlasClassification ent1 = classificationType.createDefaultValue();
    String jsonString = AtlasType.toJson(ent1);
    AtlasClassification ent2 = AtlasType.fromJson(jsonString, AtlasClassification.class);
    classificationType.normalizeAttributeValues(ent2);
    assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasClassification with superTypes");
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasClassificationType(org.apache.atlas.type.AtlasClassificationType) Test(org.testng.annotations.Test)

Example 9 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class TestAtlasEntity method testEntitySerDeWithSuperType.

@Test
public void testEntitySerDeWithSuperType() throws AtlasBaseException {
    AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperType();
    AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
    AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName());
    assertNotNull(entityType);
    AtlasEntity ent1 = entityType.createDefaultValue();
    String jsonString = AtlasType.toJson(ent1);
    AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class);
    entityType.normalizeAttributeValues(ent2);
    assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity with superType");
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Test(org.testng.annotations.Test)

Example 10 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class TestAtlasEntity method testEntitySerDeWithSuperTypes.

@Test
public void testEntitySerDeWithSuperTypes() throws AtlasBaseException {
    AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperTypes();
    AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
    AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName());
    assertNotNull(entityType);
    AtlasEntity ent1 = entityType.createDefaultValue();
    String jsonString = AtlasType.toJson(ent1);
    AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class);
    entityType.normalizeAttributeValues(ent2);
    assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity with superTypes");
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Test(org.testng.annotations.Test)

Aggregations

AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)15 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)6 Test (org.testng.annotations.Test)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)4 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)3 GraphBackedSearchIndexer (org.apache.atlas.repository.graph.GraphBackedSearchIndexer)3 AtlasClassificationType (org.apache.atlas.type.AtlasClassificationType)3 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)3 TypesDef (org.apache.atlas.typesystem.TypesDef)2 ClassType (org.apache.atlas.typesystem.types.ClassType)2 BeforeClass (org.testng.annotations.BeforeClass)2 ArrayList (java.util.ArrayList)1 AtlasException (org.apache.atlas.AtlasException)1 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)1 TypesChangeListener (org.apache.atlas.listener.TypesChangeListener)1 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)1 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)1 InMemoryEntityAuditRepository (org.apache.atlas.repository.audit.InMemoryEntityAuditRepository)1 GraphBackedTypeStore (org.apache.atlas.repository.typestore.GraphBackedTypeStore)1 ITypeStore (org.apache.atlas.repository.typestore.ITypeStore)1