Search in sources :

Example 11 with ServiceErrorList

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);
}
Also used : Response(javax.ws.rs.core.Response) ServiceErrorList(com.ibm.cohort.engine.api.service.model.ServiceErrorList) Test(org.junit.Test)

Example 12 with ServiceErrorList

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);
}
Also used : Response(javax.ws.rs.core.Response) FhirClientConnectionException(ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException) ServiceErrorList(com.ibm.cohort.engine.api.service.model.ServiceErrorList) ConnectException(java.net.ConnectException) Test(org.junit.Test)

Example 13 with ServiceErrorList

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);
}
Also used : Response(javax.ws.rs.core.Response) AuthenticationException(ca.uhn.fhir.rest.server.exceptions.AuthenticationException) ServiceErrorList(com.ibm.cohort.engine.api.service.model.ServiceErrorList) Test(org.junit.Test)

Example 14 with ServiceErrorList

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);
}
Also used : Response(javax.ws.rs.core.Response) ServiceErrorList(com.ibm.cohort.engine.api.service.model.ServiceErrorList) Test(org.junit.Test)

Example 15 with ServiceErrorList

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);
}
Also used : Response(javax.ws.rs.core.Response) FhirClientConnectionException(ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException) ServiceErrorList(com.ibm.cohort.engine.api.service.model.ServiceErrorList) Test(org.junit.Test)

Aggregations

ServiceErrorList (com.ibm.cohort.engine.api.service.model.ServiceErrorList)17 Response (javax.ws.rs.core.Response)15 Test (org.junit.Test)15 FhirClientConnectionException (ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException)7 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)4 AuthenticationException (ca.uhn.fhir.rest.server.exceptions.AuthenticationException)2 ConnectException (java.net.ConnectException)2 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)2 CqlException (org.opencds.cqf.cql.engine.exception.CqlException)2 BaseServerResponseException (ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException)1 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 MismatchedInputException (com.fasterxml.jackson.databind.exc.MismatchedInputException)1 ErrorSource (com.ibm.cohort.engine.api.service.model.ServiceErrorList.ErrorSource)1 ServiceError (com.ibm.watson.service.base.model.ServiceError)1 IAttachment (com.ibm.websphere.jaxrs20.multipart.IAttachment)1 IMultipartBody (com.ibm.websphere.jaxrs20.multipart.IMultipartBody)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 Status (javax.ws.rs.core.Response.Status)1