use of com.ibm.cohort.engine.api.service.model.ServiceErrorList in project quality-measure-and-cohort-service by Alvearie.
the class CohortServiceExceptionMapperTest method testToResponseFhirClientConnectionExceptionUnknownHost.
@Test
public void testToResponseFhirClientConnectionExceptionUnknownHost() throws Exception {
Response response = exMapper.toResponse(new FhirClientConnectionException("Something bad got input").initCause(new java.net.UnknownHostException("bad host")));
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(500);
expected.getErrors().add(newServiceError(500, "Something bad got input", "Reason: FhirClientConnectionException"));
expected.getErrors().add(newServiceError(404, "bad host", null));
expected.setErrorSource(ErrorSource.COHORT_SERVICE);
testErrorListEquality(expected, actual);
}
use of com.ibm.cohort.engine.api.service.model.ServiceErrorList in project quality-measure-and-cohort-service by Alvearie.
the class CohortServiceExceptionMapperTest method testToResponseResourceNotFoundExceptionNotOperationOutcome.
@Test
public void testToResponseResourceNotFoundExceptionNotOperationOutcome() throws Exception {
ResourceNotFoundException ex = new ResourceNotFoundException("Bad URL");
ex.setResponseBody("Bad Body");
Response response = new CohortServiceExceptionMapper().toResponse(ex);
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(400);
expected.getErrors().add(newServiceError(404, "FHIR Resource Not Found: Bad URL", "Bad Body"));
expected.setErrorSource(ErrorSource.FHIR_SERVER);
testErrorListEquality(expected, actual);
}
use of com.ibm.cohort.engine.api.service.model.ServiceErrorList in project quality-measure-and-cohort-service by Alvearie.
the class CohortServiceExceptionMapperTest method testToResponseIllegalArgumentException.
@Test
public void testToResponseIllegalArgumentException() throws Exception {
Response response = exMapper.toResponse(new IllegalArgumentException("Something bad got input", new IllegalArgumentException("Nested exception")));
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(400);
expected.getErrors().add(newServiceError(400, "Something bad got input", ""));
expected.getErrors().add(newServiceError(400, "Nested exception", null));
expected.setErrorSource(ErrorSource.COHORT_SERVICE);
testErrorListEquality(expected, actual);
}
use of com.ibm.cohort.engine.api.service.model.ServiceErrorList in project quality-measure-and-cohort-service by Alvearie.
the class CohortServiceExceptionMapperTest method testToResponseResourceNotFoundExceptionHAPIFormat.
@Test
public void testToResponseResourceNotFoundExceptionHAPIFormat() throws Exception {
OperationOutcome outcome = new OperationOutcome();
outcome.getText().setStatusAsString("generated");
outcome.getIssueFirstRep().setSeverity(IssueSeverity.ERROR).setCode(OperationOutcome.IssueType.PROCESSING).setDiagnostics("Resource Patient/something is not found");
ResourceNotFoundException ex = new ResourceNotFoundException("Error", outcome);
ex.setResponseBody(parser.encodeResourceToString(outcome));
Response response = new CohortServiceExceptionMapper().toResponse(ex);
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(400);
expected.getErrors().add(newServiceError(404, "FHIR Resource Not Found: Error", "{\"resourceType\":\"OperationOutcome\",\"text\":{\"status\":\"generated\"},\"issue\":[{\"severity\":\"error\",\"code\":\"processing\",\"diagnostics\":\"Resource Patient/something is not found\"}]}"));
expected.setErrorSource(ErrorSource.FHIR_SERVER);
testErrorListEquality(expected, actual);
}
use of com.ibm.cohort.engine.api.service.model.ServiceErrorList in project quality-measure-and-cohort-service by Alvearie.
the class CohortServiceExceptionMapperTest method testToResponseCqlException.
@Test
public void testToResponseCqlException() throws Exception {
Response response = exMapper.toResponse(new CqlException("Unexpected exception caught during execution", new IllegalArgumentException("Failed to resolve ValueSet")));
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(400);
expected.getErrors().add(newServiceError(400, "Unexpected exception caught during execution", ""));
expected.getErrors().add(newServiceError(400, "Failed to resolve ValueSet", null));
expected.setErrorSource(ErrorSource.COHORT_SERVICE);
testErrorListEquality(expected, actual);
}
Aggregations