Search in sources :

Example 36 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef 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 37 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef 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)

Example 38 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class TestAtlasEntity method testEntitySerDe.

@Test
public void testEntitySerDe() throws AtlasBaseException {
    AtlasEntityDef entityDef = ModelTestUtil.getEntityDef();
    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");
}
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 39 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class TestAtlasEntityType method createTableEntityDefWithOwnedRefOnInvalidType.

private AtlasEntityDef createTableEntityDefWithOwnedRefOnInvalidType() {
    AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE);
    AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING);
    attrName.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));
    table.addAttribute(attrName);
    return table;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)

Example 40 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class TestAtlasEntityType method createTableEntityDef.

private AtlasEntityDef createTableEntityDef() {
    AtlasEntityDef table = new AtlasEntityDef(TYPE_TABLE);
    AtlasAttributeDef attrName = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING);
    AtlasAttributeDef attrColumns = new AtlasAttributeDef(ATTR_COLUMNS, AtlasBaseTypeDef.getArrayTypeName(TYPE_COLUMN));
    attrColumns.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));
    table.addAttribute(attrName);
    table.addAttribute(attrColumns);
    return table;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasConstraintDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)

Aggregations

AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)67 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)30 Test (org.testng.annotations.Test)25 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)24 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)24 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)19 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)18 ArrayList (java.util.ArrayList)17 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)17 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)14 HashMap (java.util.HashMap)12 AtlasTransientTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)9 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)7 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)7 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)6 AtlasErrorCode (org.apache.atlas.AtlasErrorCode)5 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)5 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)5 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)5