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");
}
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");
}
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");
}
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;
}
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;
}
Aggregations