use of org.apache.atlas.model.typedef.AtlasEntityDef in project atlas by apache.
the class RestUtilsTest method testV1toV2toV1Conversion.
private void testV1toV2toV1Conversion(List<ClassTypeDefinition> typesToTest, boolean[] compositeExpected) throws AtlasBaseException {
List<AtlasEntityDef> convertedEntityDefs = convertV1toV2(typesToTest);
AtlasTypeRegistry registry = createRegistry(convertedEntityDefs);
for (int i = 0; i < convertedEntityDefs.size(); i++) {
AtlasEntityDef def = convertedEntityDefs.get(i);
for (AtlasAttributeDef attrDef : def.getAttributeDefs()) {
AtlasAttributeDef converted = convertToJsonAndBack(registry, def, attrDef, compositeExpected[i]);
Assert.assertEquals(converted, attrDef);
}
}
List<ClassTypeDefinition> convertedBackTypeDefs = convertV2toV1(convertedEntityDefs);
for (int i = 0; i < typesToTest.size(); i++) {
ClassTypeDefinition convertedBack = convertedBackTypeDefs.get(i);
Assert.assertEquals(convertedBack, typesToTest.get(i));
List<AttributeDefinition> attributeDefinitions = convertedBack.getAttributeDefinitions();
if (attributeDefinitions.size() > 0) {
Assert.assertEquals(attributeDefinitions.get(0).getIsComposite(), compositeExpected[i]);
}
}
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project atlas by apache.
the class RestUtilsTest method convertV2toV1.
private List<ClassTypeDefinition> convertV2toV1(List<AtlasEntityDef> toConvert) throws AtlasBaseException {
AtlasTypeRegistry reg = createRegistry(toConvert);
List<ClassTypeDefinition> result = new ArrayList<>(toConvert.size());
for (int i = 0; i < toConvert.size(); i++) {
AtlasEntityDef entityDef = toConvert.get(i);
AtlasEntityType entity = reg.getEntityTypeByName(entityDef.getName());
ClassTypeDefinition converted = TypeConverterUtil.toTypesDef(entity, reg).getClassTypes().get(0);
result.add(converted);
}
return result;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project atlas by apache.
the class TypeAttributeDifferenceTest method differentSubset_ReturnsDifference.
@Test
public void differentSubset_ReturnsDifference() throws Exception {
AtlasEntityDef existing = getAtlasEntityDefWithAttributes("name", "qualifiedName");
AtlasEntityDef incoming = getAtlasEntityDefWithAttributes("name");
List<AtlasStructDef.AtlasAttributeDef> actualAttributes = invokeGetAttributesAbsentInExisting(existing, incoming);
List<AtlasStructDef.AtlasAttributeDef> expectedAttributes = getAtlasAttributeDefs();
Assert.assertEquals(actualAttributes, expectedAttributes);
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project atlas by apache.
the class TypeAttributeDifferenceTest method entityDefWithNoAttributes.
@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);
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project atlas by apache.
the class TypeAttributeDifference method updateEntityDef.
private void updateEntityDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {
for (AtlasEntityDef def : typeDefinitionMap.getEntityDefs()) {
AtlasEntityDef existing = typeRegistry.getEntityDefByName(def.getName());
if (existing != null && addAttributes(existing, def)) {
typeDefStore.updateEntityDefByName(existing.getName(), existing);
result.incrementMeticsCounter("typedef:entitydef:update");
}
}
}
Aggregations