Search in sources :

Example 76 with AtlasEntityDef

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]);
        }
    }
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry)

Example 77 with AtlasEntityDef

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;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Example 78 with AtlasEntityDef

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);
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) Test(org.testng.annotations.Test)

Example 79 with AtlasEntityDef

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);
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 80 with AtlasEntityDef

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");
        }
    }
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef)

Aggregations

AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)141 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)55 Test (org.testng.annotations.Test)51 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)40 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)37 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)35 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)31 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)31 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)30 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)21 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)14 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)13 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)13 AtlasTransientTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)13 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)12 AtlasErrorCode (org.apache.atlas.AtlasErrorCode)11 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)9 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)8 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)8