use of com.ibm.cohort.engine.api.service.model.ServiceErrorList in project quality-measure-and-cohort-service by Alvearie.
the class CohortServiceExceptionMapperTest method testToResponseUnsupportedOperationException.
@Test
public void testToResponseUnsupportedOperationException() throws Exception {
Response response = exMapper.toResponse(new UnsupportedOperationException("No support for that yet."));
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(400);
expected.getErrors().add(newServiceError(400, "No support for that yet.", ""));
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 testToResponseFhirClientConnectionExceptionUnknownHostConnectionRefused.
@Test
public void testToResponseFhirClientConnectionExceptionUnknownHostConnectionRefused() throws Exception {
Response response = exMapper.toResponse(new FhirClientConnectionException("Something bad got input").initCause(new java.net.ConnectException("connection refused")));
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, "connection refused", 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 testToResponseAuthenticationException.
@Test
public void testToResponseAuthenticationException() throws Exception {
Response response = exMapper.toResponse(new AuthenticationException());
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(400);
expected.getErrors().add(newServiceError(401, "Client unauthorized", "Could not authenticate with FHIR server."));
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 testToResponseNPE.
@Test
public void testToResponseNPE() throws Exception {
Response response = exMapper.toResponse(new NullPointerException());
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(500);
expected.getErrors().add(newServiceError(500, null, 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 testToResponseFhirClientConnectionException.
@Test
public void testToResponseFhirClientConnectionException() throws Exception {
Response response = exMapper.toResponse(new FhirClientConnectionException("Something bad got input"));
ServiceErrorList actual = (ServiceErrorList) response.getEntity();
ServiceErrorList expected = new ServiceErrorList();
expected.setStatusCode(500);
expected.getErrors().add(newServiceError(500, "Something bad got input", "Reason: FhirClientConnectionException"));
expected.setErrorSource(ErrorSource.COHORT_SERVICE);
testErrorListEquality(expected, actual);
}
Aggregations