/** * @return a sample response. */ public static Response createResponse() { Response response = new Response(); response.setStatus(Status.FAILURE); response.getErrors().addAll(Arrays.asList( new ErrorInfo(ErrorCode.PATIENT_ID_DOES_NOT_MATCH, "context1", Severity.ERROR, "location1", null), new ErrorInfo(ErrorCode.SQL_ERROR, "context2", Severity.WARNING, null, null), new ErrorInfo(ErrorCode._USER_DEFINED, "context3", Severity.ERROR, "location3", "MyCustomErrorCode"))); return response; }
protected AdhocQueryResponse processRequest(AdhocQueryRequest body) { Exchange result = process(body); Exception exception = Exchanges.extractException(result); if (exception != null) { log.debug(getClass().getSimpleName() + " service failed", exception); QueryResponse errorResponse = new QueryResponse( exception, ErrorCode.REGISTRY_METADATA_ERROR, ErrorCode.REGISTRY_ERROR, homeCommunityId); errorResponse.getErrors().get(0).setLocation(homeCommunityId); return EbXML30Converters.convert(errorResponse); } return Exchanges.resultMessage(result).getBody(AdhocQueryResponse.class); } }
@Test public void testInvalidErrorCode() { response.getErrors().add(new ErrorInfo(null, null, Severity.ERROR, null, null)); expectFailure(INVALID_ERROR_CODE_IN_RESPONSE); }
protected RetrieveDocumentSetResponseType processRequest(T body) { Exchange result = process(body); Exception exception = Exchanges.extractException(result); if (exception != null) { log.debug(getClass().getSimpleName() + " service failed", exception); RetrievedDocumentSet errorResponse = new RetrievedDocumentSet( exception, ErrorCode.REPOSITORY_METADATA_ERROR, ErrorCode.REPOSITORY_ERROR, homeCommunityId); if (homeCommunityId != null) { errorResponse.getErrors().get(0).setLocation(homeCommunityId); } return EbXML30Converters.convert(errorResponse); } return Exchanges.resultMessage(result).getBody(RetrieveDocumentSetResponseType.class); } }