Search in sources :

Example 1 with TypeUpdateException

use of org.apache.atlas.typesystem.types.TypeUpdateException in project incubator-atlas by apache.

the class StoreBackedTypeCacheMetadataServiceTest method testInvalidUpdateType.

@Test
public void testInvalidUpdateType() throws Exception {
    // Cache should be empty
    Assert.assertFalse(storeBackedTypeCache.isCachedInMemory(TestUtils.TABLE_TYPE));
    HierarchicalTypeDefinition<ClassType> classTypeDef = TypesUtil.createClassTypeDef(TestUtils.TABLE_TYPE, ImmutableSet.<String>of(), new AttributeDefinition("attr1", DataTypes.STRING_TYPE.getName(), Multiplicity.OPTIONAL, false, null));
    String json = TypesSerialization.toJson(classTypeDef, false);
    // Try to update the type with disallowed changes.  Should fail with TypeUpdateException.
    try {
        metadataService.updateType(json);
        Assert.fail(TypeUpdateException.class.getSimpleName() + " was expected but none thrown");
    } catch (TypeUpdateException e) {
    // good
    }
    // hive_table type should now be cached.
    Assert.assertTrue(storeBackedTypeCache.isCachedInMemory(TestUtils.TABLE_TYPE));
}
Also used : AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) TypeUpdateException(org.apache.atlas.typesystem.types.TypeUpdateException) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Aggregations

AttributeDefinition (org.apache.atlas.typesystem.types.AttributeDefinition)1 ClassType (org.apache.atlas.typesystem.types.ClassType)1 TypeUpdateException (org.apache.atlas.typesystem.types.TypeUpdateException)1 Test (org.testng.annotations.Test)1