use of org.apache.atlas.AtlasServiceException in project incubator-atlas by apache.
the class EntityJerseyResourceIT method testSubmitEntityWithBadDateFormat.
@Test
public void testSubmitEntityWithBadDateFormat() throws Exception {
try {
String dbName = "db" + randomString();
String tableName = "table" + randomString();
Referenceable hiveDBInstance = createHiveDBInstanceBuiltIn(dbName);
Id dbId = createInstance(hiveDBInstance);
Referenceable hiveTableInstance = createHiveTableInstanceBuiltIn(dbName, tableName, dbId);
hiveTableInstance.set("lastAccessTime", "2014-07-11");
Id tableId = createInstance(hiveTableInstance);
Assert.fail("Was expecting an exception here ");
} catch (AtlasServiceException e) {
Assert.assertTrue(e.getMessage().contains("\"error\":\"Cannot convert value '2014-07-11' to datatype date\""));
}
}
use of org.apache.atlas.AtlasServiceException in project incubator-atlas by apache.
the class EntityV2JerseyResourceIT method testDeleteExistentTraitNonExistentForEntity.
@Test(dependsOnMethods = "testSubmitEntity")
public void testDeleteExistentTraitNonExistentForEntity() throws Exception {
final String guid = createHiveTable().getGuid();
final String traitName = "PII_Trait" + randomString();
AtlasClassificationDef piiTrait = AtlasTypeUtil.createTraitTypeDef(traitName, ImmutableSet.<String>of(), AtlasTypeUtil.createRequiredAttrDef("type", "string"));
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(piiTrait);
createType(typesDef);
try {
atlasClientV2.deleteClassification(guid, traitName);
fail("Deletion should've failed for non-existent trait association");
} catch (AtlasServiceException ex) {
Assert.assertNotNull(ex.getStatus());
assertEquals(ex.getStatus(), ClientResponse.Status.NOT_FOUND);
}
}
use of org.apache.atlas.AtlasServiceException in project incubator-atlas by apache.
the class TypedefsJerseyResourceIT method testInvalidGets.
@Test
public void testInvalidGets() throws Exception {
try {
AtlasEnumDef byName = clientV2.getEnumDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasEnumDef byGuid = clientV2.getEnumDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasStructDef byName = clientV2.getStructDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasStructDef byGuid = clientV2.getStructDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasClassificationDef byName = clientV2.getClassificationDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasClassificationDef byGuid = clientV2.getClassificationDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasEntityDef byName = clientV2.getEntityDefByName("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
try {
AtlasEntityDef byGuid = clientV2.getEntityDefByGuid("blah");
fail("Get for invalid name should have reported a failure");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.NOT_FOUND.getStatusCode(), "Should've returned a 404");
}
}
use of org.apache.atlas.AtlasServiceException in project incubator-atlas by apache.
the class TypedefsJerseyResourceIT method verifyByNameAndGUID.
private void verifyByNameAndGUID(AtlasBaseTypeDef typeDef) {
try {
AtlasBaseTypeDef byName = null;
if (typeDef.getCategory() == TypeCategory.ENUM) {
byName = clientV2.getEnumDefByName(typeDef.getName());
} else if (typeDef.getCategory() == TypeCategory.ENTITY) {
byName = clientV2.getEntityDefByName(typeDef.getName());
} else if (typeDef.getCategory() == TypeCategory.CLASSIFICATION) {
byName = clientV2.getClassificationDefByName(typeDef.getName());
} else if (typeDef.getCategory() == TypeCategory.STRUCT) {
byName = clientV2.getStructDefByName(typeDef.getName());
}
assertNotNull(byName);
} catch (AtlasServiceException e) {
fail("Get byName should've succeeded", e);
}
if (StringUtils.isNotBlank(typeDef.getGuid())) {
try {
AtlasBaseTypeDef byGuid = null;
if (typeDef.getCategory() == TypeCategory.ENUM) {
byGuid = clientV2.getEnumDefByGuid(typeDef.getGuid());
} else if (typeDef.getCategory() == TypeCategory.ENTITY) {
byGuid = clientV2.getEntityDefByGuid(typeDef.getGuid());
} else if (typeDef.getCategory() == TypeCategory.CLASSIFICATION) {
byGuid = clientV2.getClassificationDefByGuid(typeDef.getGuid());
} else if (typeDef.getCategory() == TypeCategory.STRUCT) {
byGuid = clientV2.getStructDefByGuid(typeDef.getGuid());
}
assertNotNull(byGuid);
} catch (AtlasServiceException e) {
fail("Get byGuid should've succeeded", e);
}
}
}
Aggregations