Search in sources :

Example 36 with AtlasTypesDef

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

the class AtlasTypeDefGraphStoreTest method testCreateWithValidAttributes.

@Test(dependsOnMethods = "testGet")
public void testCreateWithValidAttributes() {
    AtlasTypesDef hiveTypes = TestUtilsV2.defineHiveTypes();
    try {
        AtlasTypesDef createdTypes = typeDefStore.createTypesDef(hiveTypes);
        assertEquals(hiveTypes.getEnumDefs(), createdTypes.getEnumDefs(), "Data integrity issue while persisting");
        assertEquals(hiveTypes.getStructDefs(), createdTypes.getStructDefs(), "Data integrity issue while persisting");
        assertEquals(hiveTypes.getClassificationDefs(), createdTypes.getClassificationDefs(), "Data integrity issue while persisting");
        assertEquals(hiveTypes.getEntityDefs(), createdTypes.getEntityDefs(), "Data integrity issue while persisting");
    } catch (AtlasBaseException e) {
        fail("Hive Type creation should've succeeded");
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Example 37 with AtlasTypesDef

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

the class AtlasTypeDefGraphStoreTest method testSearchFunctionality.

@Test(dependsOnMethods = "testGet")
public void testSearchFunctionality() {
    SearchFilter searchFilter = new SearchFilter();
    searchFilter.setParam(SearchFilter.PARAM_SUPERTYPE, "Person");
    try {
        AtlasTypesDef typesDef = typeDefStore.searchTypesDef(searchFilter);
        assertNotNull(typesDef);
        assertNotNull(typesDef.getEntityDefs());
        assertEquals(typesDef.getEntityDefs().size(), 3);
    } catch (AtlasBaseException e) {
        fail("Search should've succeeded", e);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) SearchFilter(org.apache.atlas.model.SearchFilter) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Example 38 with AtlasTypesDef

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

the class AtlasTypeDefGraphStoreTest method testTypeDeletionAndRecreate.

@Test
public void testTypeDeletionAndRecreate() {
    AtlasClassificationDef aTag = new AtlasClassificationDef("testTag");
    AtlasAttributeDef attributeDef = new AtlasAttributeDef("testAttribute", "string", true, AtlasAttributeDef.Cardinality.SINGLE, 0, 1, false, true, Collections.<AtlasStructDef.AtlasConstraintDef>emptyList());
    aTag.addAttribute(attributeDef);
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.setClassificationDefs(Arrays.asList(aTag));
    try {
        typeDefStore.createTypesDef(typesDef);
    } catch (AtlasBaseException e) {
        fail("Tag creation should've succeeded");
    }
    try {
        typeDefStore.deleteTypesDef(typesDef);
    } catch (AtlasBaseException e) {
        fail("Tag deletion should've succeeded");
    }
    aTag = new AtlasClassificationDef("testTag");
    attributeDef = new AtlasAttributeDef("testAttribute", "int", true, AtlasAttributeDef.Cardinality.SINGLE, 0, 1, false, true, Collections.<AtlasStructDef.AtlasConstraintDef>emptyList());
    aTag.addAttribute(attributeDef);
    typesDef.setClassificationDefs(Arrays.asList(aTag));
    try {
        typeDefStore.createTypesDef(typesDef);
    } catch (AtlasBaseException e) {
        fail("Tag re-creation should've succeeded");
    }
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Example 39 with AtlasTypesDef

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

the class AtlasTypeDefGraphStoreTest method testCreateWithInvalidSuperTypes.

@Test(dependsOnMethods = "testGet")
public void testCreateWithInvalidSuperTypes() {
    AtlasTypesDef typesDef;
    // Test Classification with supertype
    AtlasClassificationDef classificationDef = TestUtilsV2.getClassificationWithInvalidSuperType();
    typesDef = new AtlasTypesDef();
    typesDef.getClassificationDefs().add(classificationDef);
    try {
        AtlasTypesDef created = typeDefStore.createTypesDef(typesDef);
        fail("Classification creation with invalid supertype should've failed");
    } catch (AtlasBaseException e) {
        typesDef = null;
    }
    // Test Entity with supertype
    AtlasEntityDef entityDef = TestUtilsV2.getEntityWithInvalidSuperType();
    typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(entityDef);
    try {
        AtlasTypesDef created = typeDefStore.createTypesDef(typesDef);
        fail("Entity creation with invalid supertype should've failed");
    } catch (AtlasBaseException e) {
    }
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Example 40 with AtlasTypesDef

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

the class AtlasTypeDefGraphStoreTest method testUpdateWithMandatoryFields.

@Test(enabled = false, dependsOnMethods = { "testCreateDept" })
public void testUpdateWithMandatoryFields() {
    AtlasTypesDef atlasTypesDef = TestUtilsV2.defineInvalidUpdatedDeptEmployeeTypes();
    List<AtlasEnumDef> enumDefsToUpdate = atlasTypesDef.getEnumDefs();
    List<AtlasClassificationDef> classificationDefsToUpdate = atlasTypesDef.getClassificationDefs();
    List<AtlasStructDef> structDefsToUpdate = atlasTypesDef.getStructDefs();
    List<AtlasEntityDef> entityDefsToUpdate = atlasTypesDef.getEntityDefs();
    AtlasTypesDef onlyEnums = new AtlasTypesDef(enumDefsToUpdate, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
    AtlasTypesDef onlyStructs = new AtlasTypesDef(Collections.EMPTY_LIST, structDefsToUpdate, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
    AtlasTypesDef onlyClassification = new AtlasTypesDef(Collections.EMPTY_LIST, Collections.EMPTY_LIST, classificationDefsToUpdate, Collections.EMPTY_LIST);
    AtlasTypesDef onlyEntities = new AtlasTypesDef(Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, entityDefsToUpdate);
    try {
        AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyEnums);
        assertNotNull(updated);
    } catch (AtlasBaseException ignored) {
    }
    try {
        AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyClassification);
        assertNotNull(updated);
        assertEquals(updated.getClassificationDefs().size(), 0, "Updates should've failed");
    } catch (AtlasBaseException ignored) {
    }
    try {
        AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyStructs);
        assertNotNull(updated);
        assertEquals(updated.getStructDefs().size(), 0, "Updates should've failed");
    } catch (AtlasBaseException ignored) {
    }
    try {
        AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyEntities);
        assertNotNull(updated);
        assertEquals(updated.getEntityDefs().size(), 0, "Updates should've failed");
    } catch (AtlasBaseException ignored) {
    }
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Aggregations

AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)118 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)54 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)39 Test (org.testng.annotations.Test)39 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)30 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)22 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)22 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)20 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)19 ArrayList (java.util.ArrayList)18 SearchFilter (org.apache.atlas.model.SearchFilter)15 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)15 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)14 BeforeClass (org.testng.annotations.BeforeClass)14 HashMap (java.util.HashMap)13 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)13 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)12 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)9 MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)8 AtlasServiceException (org.apache.atlas.AtlasServiceException)7