final NiFiTypes.EntityDefinition def = ENTITIES.get(typeName); final AtlasEntityDef entity = new AtlasEntityDef(); type.getEntityDefs().add(entity);
@Test public void entityDefWithNoAttributes() throws Exception { AtlasEntityDef existing = new AtlasEntityDef(); AtlasEntityDef incoming = new AtlasEntityDef(); List<AtlasStructDef.AtlasAttributeDef> expectedAttributes = new ArrayList<>(); List<AtlasStructDef.AtlasAttributeDef> actualAttributes = invokeGetAttributesAbsentInExisting(existing, incoming); Assert.assertEquals(actualAttributes, expectedAttributes); }
@Test public void testEntityDefSerDeEmpty() { AtlasEntityDef entityDef = new AtlasEntityDef("emptyEntityDef"); String jsonString = AtlasType.toJson(entityDef); AtlasEntityDef entityDef2 = AtlasType.fromJson(jsonString, AtlasEntityDef.class); assertEquals(entityDef2, entityDef, "Incorrect serialization/deserialization of AtlasEntityDef"); }
private AtlasEntityDef toEntityDef(AtlasVertex vertex) throws AtlasBaseException { AtlasEntityDef ret = null; if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.CLASS)) { ret = new AtlasEntityDef(); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore); ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); } return ret; } }
private AtlasEntityDef toEntityDef(AtlasVertex vertex) throws AtlasBaseException { AtlasEntityDef ret = null; if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.CLASS)) { ret = new AtlasEntityDef(); AtlasStructDefStoreV2.toStructDef(vertex, ret, typeDefStore); ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex)); } return ret; } }
@Test public void testEntityDefSerDeEmpty() { AtlasEntityDef entityDef = new AtlasEntityDef("emptyEntityDef"); String jsonString = AtlasType.toJson(entityDef); AtlasEntityDef entityDef2 = AtlasType.fromJson(jsonString, AtlasEntityDef.class); assertEquals(entityDef2, entityDef, "Incorrect serialization/deserialization of AtlasEntityDef"); }
private AtlasEntityDef getAtlasEntityDefWithAttributes(String... attributeNames) { AtlasEntityDef e = new AtlasEntityDef(); for (AtlasStructDef.AtlasAttributeDef a : getAtlasAttributeDefs(attributeNames)) { e.addAttribute(a); } return e; }
private AtlasEntityDef getAtlasEntityDefWithAttributes(String... attributeNames) { AtlasEntityDef e = new AtlasEntityDef(); for (AtlasStructDef.AtlasAttributeDef a : getAtlasAttributeDefs(attributeNames)) { e.addAttribute(a); } return e; }
private AtlasEntityDef createColumnEntityDefWithInvaidAttributeTypeForInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_NAME); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; }
private AtlasEntityDef createColumnEntityDef() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_COLUMNS); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; } }
private AtlasEntityDef createColumnEntityDefWithNonExistingInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, "non-existing:" + ATTR_COLUMNS); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; }
private AtlasEntityDef createColumnEntityDefWithInvalidInverseAttributeType() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_NAME); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; }
private AtlasEntityDef createColumnEntityDefWithInvalidInverseAttributeType() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_NAME); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; }
private AtlasEntityDef createColumnEntityDefWithInvaidAttributeTypeForInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_NAME, AtlasBaseTypeDef.ATLAS_TYPE_STRING); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_NAME); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; }
private AtlasEntityDef createColumnEntityDef() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); Map<String, Object> params = new HashMap<>(); params.put(AtlasConstraintDef.CONSTRAINT_PARAM_ATTRIBUTE, ATTR_COLUMNS); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF, params)); column.addAttribute(attrTable); return column; } }
private AtlasEntityDef createColumnEntityDefWithMissingInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF)); column.addAttribute(attrTable); return column; }
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; }
private AtlasEntityDef createColumnEntityDefWithMissingInverseAttribute() { AtlasEntityDef column = new AtlasEntityDef(TYPE_COLUMN); AtlasAttributeDef attrTable = new AtlasAttributeDef(ATTR_TABLE, TYPE_TABLE); attrTable.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_INVERSE_REF)); column.addAttribute(attrTable); return column; }
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; }
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; }