use of org.apache.atlas.AtlasErrorCode in project incubator-atlas by apache.
the class TestAtlasEntityType method testConstraintInValidInverseRef_InvalidAttributeTypeForInverseAttribute.
@Test
public void testConstraintInValidInverseRef_InvalidAttributeTypeForInverseAttribute() {
AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
AtlasTransientTypeRegistry ttr = null;
boolean commit = false;
List<AtlasEntityDef> entityDefs = new ArrayList<>();
AtlasErrorCode errorCode = null;
entityDefs.add(createTableEntityDef());
entityDefs.add(createColumnEntityDefWithInvaidAttributeTypeForInverseAttribute());
try {
ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addTypes(entityDefs);
commit = true;
} catch (AtlasBaseException excp) {
errorCode = excp.getAtlasErrorCode();
} finally {
typeRegistry.releaseTypeRegistryForUpdate(ttr, commit);
}
assertEquals(errorCode, AtlasErrorCode.CONSTRAINT_INVERSE_REF_ATTRIBUTE_INVALID_TYPE, "expected invalid constraint failure - missing refAttribute");
}
use of org.apache.atlas.AtlasErrorCode in project incubator-atlas by apache.
the class AtlasBaseExceptionMapper method buildAtlasBaseExceptionResponse.
protected Response buildAtlasBaseExceptionResponse(AtlasBaseException baseException) {
Map<String, String> errorJsonMap = new LinkedHashMap<>();
AtlasErrorCode errorCode = baseException.getAtlasErrorCode();
errorJsonMap.put("errorCode", errorCode.getErrorCode());
errorJsonMap.put("errorMessage", baseException.getMessage());
Response.ResponseBuilder responseBuilder = Response.status(errorCode.getHttpCode());
// No body for 204 (and maybe 304)
if (Response.Status.NO_CONTENT != errorCode.getHttpCode()) {
responseBuilder.entity(AtlasType.toJson(errorJsonMap));
}
return responseBuilder.build();
}
use of org.apache.atlas.AtlasErrorCode in project incubator-atlas by apache.
the class TestAtlasEntityType method testConstraintInValidInverseRef_MissingParams.
@Test
public void testConstraintInValidInverseRef_MissingParams() {
AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
AtlasTransientTypeRegistry ttr = null;
boolean commit = false;
List<AtlasEntityDef> entityDefs = new ArrayList<>();
AtlasErrorCode errorCode = null;
entityDefs.add(createTableEntityDef());
entityDefs.add(createColumnEntityDefWithMissingInverseAttribute());
try {
ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addTypes(entityDefs);
commit = true;
} catch (AtlasBaseException excp) {
errorCode = excp.getAtlasErrorCode();
} finally {
typeRegistry.releaseTypeRegistryForUpdate(ttr, commit);
}
assertEquals(errorCode, AtlasErrorCode.CONSTRAINT_MISSING_PARAMS, "expected invalid constraint failure - missing refAttribute");
}
use of org.apache.atlas.AtlasErrorCode in project incubator-atlas by apache.
the class TestAtlasEntityType method testConstraintInvalidOwnedRef_InvalidAttributeType.
@Test
public void testConstraintInvalidOwnedRef_InvalidAttributeType() {
AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
AtlasTransientTypeRegistry ttr = null;
boolean commit = false;
List<AtlasEntityDef> entityDefs = new ArrayList<>();
AtlasErrorCode errorCode = null;
entityDefs.add(createTableEntityDefWithOwnedRefOnInvalidType());
try {
ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addTypes(entityDefs);
commit = true;
} catch (AtlasBaseException excp) {
errorCode = excp.getAtlasErrorCode();
} finally {
typeRegistry.releaseTypeRegistryForUpdate(ttr, commit);
}
assertEquals(errorCode, AtlasErrorCode.CONSTRAINT_OWNED_REF_ATTRIBUTE_INVALID_TYPE, "expected invalid constraint failure - missing refAttribute");
}
use of org.apache.atlas.AtlasErrorCode in project incubator-atlas by apache.
the class TestAtlasEntityType method testConstraintInValidInverseRef_NonExistingAttribute.
@Test
public void testConstraintInValidInverseRef_NonExistingAttribute() {
AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
AtlasTransientTypeRegistry ttr = null;
boolean commit = false;
List<AtlasEntityDef> entityDefs = new ArrayList<>();
AtlasErrorCode errorCode = null;
entityDefs.add(createTableEntityDef());
entityDefs.add(createColumnEntityDefWithNonExistingInverseAttribute());
try {
ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addTypes(entityDefs);
commit = true;
} catch (AtlasBaseException excp) {
errorCode = excp.getAtlasErrorCode();
} finally {
typeRegistry.releaseTypeRegistryForUpdate(ttr, commit);
}
assertEquals(errorCode, AtlasErrorCode.CONSTRAINT_INVERSE_REF_INVERSE_ATTRIBUTE_NON_EXISTING, "expected invalid constraint failure - non-existing refAttribute");
}
Aggregations