diff --git a/hapi-fhir-android/.classpath b/hapi-fhir-android/.classpath index 0a155ef50de..0c4c687478f 100644 --- a/hapi-fhir-android/.classpath +++ b/hapi-fhir-android/.classpath @@ -13,6 +13,7 @@ + diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index 933d6b31e61..515e7a43fbe 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -15,6 +15,18 @@ HAPI FHIR - Android + + + + ch.qos.logback + logback-classic + test + + + ca.uhn.hapi.fhir hapi-fhir-base diff --git a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarIT.java b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarIT.java index 492b7be8c21..77eb16a2709 100644 --- a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarIT.java +++ b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/BuiltJarIT.java @@ -54,6 +54,9 @@ public class BuiltJarIT { @Test public void testParserJson() { + ourLog.info("AAAAA"); + ourLog.info("AAAAA"); + FhirContext ctx = FhirContext.forDstu2(); Observation o = new Observation(); diff --git a/hapi-fhir-android/src/test/resources/logback-test.xml b/hapi-fhir-android/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..6c4628357f7 --- /dev/null +++ b/hapi-fhir-android/src/test/resources/logback-test.xml @@ -0,0 +1,49 @@ + + + + + TRACE + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseValidatingInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseValidatingInterceptor.java index e91e32cfe72..35c869bdb99 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseValidatingInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseValidatingInterceptor.java @@ -9,6 +9,7 @@ import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.text.StrLookup; import org.apache.commons.lang3.text.StrSubstitutor; +import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.method.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.validation.FhirValidator; @@ -34,27 +35,28 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseValidatingInterceptor.class); - private Integer myAddResponseHeaderOnSeverity = ResultSeverityEnum.INFORMATION.ordinal(); + private Integer myAddResponseIssueHeaderOnSeverity = null; + private Integer myAddResponseOutcomeHeaderOnSeverity = null; private Integer myFailOnSeverity = ResultSeverityEnum.ERROR.ordinal(); - private String myResponseHeaderName = provideDefaultResponseHeaderName(); - private String myResponseHeaderValue = DEFAULT_RESPONSE_HEADER_VALUE; - private String myResponseHeaderValueNoIssues = null; - + private String myResponseIssueHeaderName = provideDefaultResponseHeaderName(); + private String myResponseIssueHeaderValue = DEFAULT_RESPONSE_HEADER_VALUE; + private String myResponseIssueHeaderValueNoIssues = null; + private String myResponseOutcomeHeaderName = provideDefaultResponseHeaderName(); private List myValidatorModules; - private void addResponseHeader(RequestDetails theRequestDetails, SingleValidationMessage theNext) { + private void addResponseIssueHeader(RequestDetails theRequestDetails, SingleValidationMessage theNext) { // Perform any string substitutions from the message format StrLookup lookup = new MyLookup(theNext); StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\'); // Log the header - String headerValue = subs.replace(myResponseHeaderValue); + String headerValue = subs.replace(myResponseIssueHeaderValue); ourLog.trace("Adding header to response: {}", headerValue); - theRequestDetails.getResponse().addHeader(myResponseHeaderName, headerValue); + theRequestDetails.getResponse().addHeader(myResponseIssueHeaderName, headerValue); } - public BaseValidatingInterceptor addValidatorModule(IValidatorModule theModule) { + public BaseValidatingInterceptor addValidatorModule(IValidatorModule theModule) { Validate.notNull(theModule, "theModule must not be null"); if (getValidatorModules() == null) { setValidatorModules(new ArrayList()); @@ -64,7 +66,7 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { } abstract ValidationResult doValidate(FhirValidator theValidator, T theRequest); - + /** * Fail the request by throwing an {@link UnprocessableEntityException} as a result of a validation failure. * Subclasses may change this behaviour by providing alternate behaviour. @@ -73,10 +75,26 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { throw new UnprocessableEntityException(theRequestDetails.getServer().getFhirContext(), theValidationResult.toOperationOutcome()); } + /** + * The name of the header specified by {@link #setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum)} + */ + public String getResponseOutcomeHeaderName() { + return myResponseOutcomeHeaderName; + } + public List getValidatorModules() { return myValidatorModules; } + /** + * If the validation produces a result with at least the given severity, a header with the name + * specified by {@link #setResponseOutcomeHeaderName(String)} will be added containing a JSON encoded + * OperationOutcome resource containing the validation results. + */ + public ResultSeverityEnum getAddResponseOutcomeHeaderOnSeverity() { + return myAddResponseOutcomeHeaderOnSeverity != null ? ResultSeverityEnum.values()[myAddResponseOutcomeHeaderOnSeverity] : null; + } + abstract String provideDefaultResponseHeaderName(); /** @@ -87,7 +105,16 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { * @see #setResponseHeaderValue(String) */ public void setAddResponseHeaderOnSeverity(ResultSeverityEnum theSeverity) { - myAddResponseHeaderOnSeverity = theSeverity != null ? theSeverity.ordinal() : null; + myAddResponseIssueHeaderOnSeverity = theSeverity != null ? theSeverity.ordinal() : null; + } + + /** + * If the validation produces a result with at least the given severity, a header with the name + * specified by {@link #setResponseOutcomeHeaderName(String)} will be added containing a JSON encoded + * OperationOutcome resource containing the validation results. + */ + public void setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum theAddResponseOutcomeHeaderOnSeverity) { + myAddResponseOutcomeHeaderOnSeverity = theAddResponseOutcomeHeaderOnSeverity != null ? theAddResponseOutcomeHeaderOnSeverity.ordinal() : null; } /** @@ -105,7 +132,7 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { */ protected void setResponseHeaderName(String theResponseHeaderName) { Validate.notBlank(theResponseHeaderName, "theResponseHeaderName must not be blank or null"); - myResponseHeaderName = theResponseHeaderName; + myResponseIssueHeaderName = theResponseHeaderName; } /** @@ -147,7 +174,7 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { */ public void setResponseHeaderValue(String theResponseHeaderValue) { Validate.notBlank(theResponseHeaderValue, "theResponseHeaderValue must not be blank or null"); - myResponseHeaderValue = theResponseHeaderValue; + myResponseIssueHeaderValue = theResponseHeaderValue; } /** @@ -155,7 +182,15 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { * threshold specified by {@link #setAddResponseHeaderOnSeverity(ResultSeverityEnum)} */ public void setResponseHeaderValueNoIssues(String theResponseHeaderValueNoIssues) { - myResponseHeaderValueNoIssues = theResponseHeaderValueNoIssues; + myResponseIssueHeaderValueNoIssues = theResponseHeaderValueNoIssues; + } + + /** + * The name of the header specified by {@link #setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum)} + */ + public void setResponseOutcomeHeaderName(String theResponseOutcomeHeaderName) { + Validate.notEmpty(theResponseOutcomeHeaderName, "theResponseOutcomeHeaderName can not be empty or null"); + myResponseOutcomeHeaderName = theResponseOutcomeHeaderName; } public void setValidatorModules(List theValidatorModules) { @@ -172,17 +207,17 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { ValidationResult validationResult = doValidate(validator, theRequest); - if (myAddResponseHeaderOnSeverity != null) { + if (myAddResponseIssueHeaderOnSeverity != null) { boolean found = false; for (SingleValidationMessage next : validationResult.getMessages()) { - if (next.getSeverity().ordinal() >= myAddResponseHeaderOnSeverity) { - addResponseHeader(theRequestDetails, next); + if (next.getSeverity().ordinal() >= myAddResponseIssueHeaderOnSeverity) { + addResponseIssueHeader(theRequestDetails, next); found = true; } } if (!found) { - if (isNotBlank(myResponseHeaderValueNoIssues)) { - theRequestDetails.getResponse().addHeader(myResponseHeaderName, myResponseHeaderValueNoIssues); + if (isNotBlank(myResponseIssueHeaderValueNoIssues)) { + theRequestDetails.getResponse().addHeader(myResponseIssueHeaderName, myResponseIssueHeaderValueNoIssues); } } } @@ -195,6 +230,21 @@ abstract class BaseValidatingInterceptor extends InterceptorAdapter { } } } + + if (myAddResponseOutcomeHeaderOnSeverity != null) { + boolean add = false; + for (SingleValidationMessage next : validationResult.getMessages()) { + if (next.getSeverity().ordinal() >= myAddResponseOutcomeHeaderOnSeverity) { + add = true; + } + } + if (add) { + IParser parser = theRequestDetails.getServer().getFhirContext().newJsonParser().setPrettyPrint(false); + String encoded = parser.encodeResourceToString(validationResult.toOperationOutcome()); + theRequestDetails.getResponse().addHeader(myResponseOutcomeHeaderName, encoded); + } + } + } private static class MyLookup extends StrLookup { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/RequestValidatingInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/RequestValidatingInterceptor.java index 1906ef5f41f..8e8d7e1d1ae 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/RequestValidatingInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/RequestValidatingInterceptor.java @@ -25,7 +25,7 @@ public class RequestValidatingInterceptor extends BaseValidatingInterceptor alphabetical - false + diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu21Config.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu21Config.java index 1a23667753f..b4515dfb63d 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu21Config.java +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/config/TestDstu21Config.java @@ -29,6 +29,7 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor; import ca.uhn.fhir.validation.IValidatorModule; +import ca.uhn.fhir.validation.ResultSeverityEnum; @Configuration @Import(CommonConfig.class) @@ -107,7 +108,10 @@ public class TestDstu21Config extends BaseJavaConfigDstu21 { RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor(); requestValidator.addValidatorModule(myInstanceValidatorDstu21); requestValidator.addValidatorModule(myQuestionnaireResponseValidatorDstu21); - requestValidator.setResponseHeaderValueNoIssues("Validation did not detect any issues"); + requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR); + requestValidator.setAddResponseHeaderOnSeverity(null); + requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + return requestValidator; } @@ -121,7 +125,18 @@ public class TestDstu21Config extends BaseJavaConfigDstu21 { responseValidator.addValidatorModule(myQuestionnaireResponseValidatorDstu21); responseValidator.setResponseHeaderValueNoIssues("Validation did not detect any issues"); responseValidator.setFailOnSeverity(null); + responseValidator.setAddResponseHeaderOnSeverity(null); + responseValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); responseValidator.addExcludeOperationType(RestOperationTypeEnum.METADATA); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.EXTENDED_OPERATION_INSTANCE); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.EXTENDED_OPERATION_SERVER); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.GET_PAGE); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.HISTORY_INSTANCE); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.HISTORY_SYSTEM); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.HISTORY_TYPE); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.SEARCH_SYSTEM); + responseValidator.addExcludeOperationType(RestOperationTypeEnum.SEARCH_TYPE); return responseValidator; } diff --git a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/RequestValidatingInterceptorDstu21Test.java b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/RequestValidatingInterceptorDstu21Test.java index 15413749ab6..edc03518dce 100644 --- a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/RequestValidatingInterceptorDstu21Test.java +++ b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/RequestValidatingInterceptorDstu21Test.java @@ -44,6 +44,7 @@ import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.util.PortUtil; import ca.uhn.fhir.validation.IValidatorModule; +import ca.uhn.fhir.validation.ResultSeverityEnum; public class RequestValidatingInterceptorDstu21Test { private static CloseableHttpClient ourClient; @@ -79,6 +80,8 @@ public class RequestValidatingInterceptorDstu21Test { @Test public void testCreateJsonInvalidNoValidatorsSpecified() throws Exception { + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -97,14 +100,15 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(422, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Request-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Request-Validation")); assertThat(responseContent, containsString("")); } @Test public void testCreateJsonInvalidNoFailure() throws Exception { myInterceptor.setFailOnSeverity(null); - + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -123,7 +127,7 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(201, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Request-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Request-Validation")); assertThat(responseContent, not(containsString(""))); } @@ -146,13 +150,14 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.trace("Response was:\n{}", responseContent); assertEquals(201, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), not(containsString("X-HAPI-Request-Validation"))); + assertThat(status.toString(), not(containsString("X-FHIR-Request-Validation"))); } @Test public void testCreateJsonValidNoValidatorsSpecifiedDefaultMessage() throws Exception { myInterceptor.setResponseHeaderValueNoIssues("NO ISSUES"); - + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -170,11 +175,13 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.trace("Response was:\n{}", responseContent); assertEquals(201, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), (containsString("X-HAPI-Request-Validation: NO ISSUES"))); + assertThat(status.toString(), (containsString("X-FHIR-Request-Validation: NO ISSUES"))); } @Test public void testCreateXmlInvalidNoValidatorsSpecified() throws Exception { + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -193,14 +200,44 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(422, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Request-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Request-Validation")); + } + + + @Test + public void testCreateXmlInvalidNoValidatorsSpecifiedOutcomeHeader() throws Exception { + myInterceptor.setAddResponseHeaderOnSeverity(null); + myInterceptor.setFailOnSeverity(null); + myInterceptor.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + + Patient patient = new Patient(); + patient.addIdentifier().setValue("002"); + patient.setGender(AdministrativeGender.MALE); + patient.addContact().addRelationship().setText("FOO"); + String encoded = ourCtx.newXmlParser().encodeResourceToString(patient); + + HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient"); + httpPost.setEntity(new StringEntity(encoded, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); + + HttpResponse status = ourClient.execute(httpPost); + + String responseContent = IOUtils.toString(status.getEntity().getContent()); + IOUtils.closeQuietly(status.getEntity().getContent()); + + ourLog.info("Response was:\n{}", status); + ourLog.info("Response was:\n{}", responseContent); + + assertEquals(201, status.getStatusLine().getStatusCode()); + assertThat(status.toString(), containsString("X-FHIR-Request-Validation: {\"resourceType\":\"OperationOutcome")); } @Test public void testCreateXmlInvalidInstanceValidator() throws Exception { IValidatorModule module = new FhirInstanceValidator(); myInterceptor.addValidatorModule(module); - + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -219,7 +256,7 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(422, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Request-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Request-Validation")); } @Test @@ -235,7 +272,7 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), not(containsString("X-HAPI-Request-Validation"))); + assertThat(status.toString(), not(containsString("X-FHIR-Request-Validation"))); assertEquals(true, ourLastRequestWasSearch); } @@ -258,7 +295,7 @@ public class RequestValidatingInterceptorDstu21Test { ourLog.trace("Response was:\n{}", responseContent); assertEquals(201, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), not(containsString("X-HAPI-Request-Validation"))); + assertThat(status.toString(), not(containsString("X-FHIR-Request-Validation"))); } @AfterClass diff --git a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/ResponseValidatingInterceptorDstu21Test.java b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/ResponseValidatingInterceptorDstu21Test.java index 917be2483fc..f9a91bca105 100644 --- a/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/ResponseValidatingInterceptorDstu21Test.java +++ b/hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/rest/server/ResponseValidatingInterceptorDstu21Test.java @@ -35,6 +35,7 @@ import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor; import ca.uhn.fhir.util.PortUtil; import ca.uhn.fhir.validation.IValidatorModule; +import ca.uhn.fhir.validation.ResultSeverityEnum; public class ResponseValidatingInterceptorDstu21Test { private static CloseableHttpClient ourClient; @@ -86,7 +87,7 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(422, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Response-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Response-Validation")); assertThat(responseContent, containsString("")); } @@ -109,14 +110,15 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.trace("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), not(containsString("X-HAPI-Response-Validation"))); + assertThat(status.toString(), not(containsString("X-FHIR-Response-Validation"))); } @Test public void testSearchJsonValidNoValidatorsSpecifiedDefaultMessage() throws Exception { myInterceptor.setResponseHeaderValueNoIssues("NO ISSUES"); - + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -133,7 +135,7 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.trace("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), (containsString("X-HAPI-Response-Validation: NO ISSUES"))); + assertThat(status.toString(), (containsString("X-FHIR-Response-Validation: NO ISSUES"))); } /** @@ -159,14 +161,15 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(422, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Response-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Response-Validation")); } @Test public void testSearchXmlInvalidInstanceValidator() throws Exception { IValidatorModule module = new FhirInstanceValidator(); myInterceptor.addValidatorModule(module); - + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); + Patient patient = new Patient(); patient.addIdentifier().setValue("002"); patient.setGender(AdministrativeGender.MALE); @@ -184,7 +187,7 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(422, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), containsString("X-HAPI-Response-Validation")); + assertThat(status.toString(), containsString("X-FHIR-Response-Validation")); } @Test @@ -204,7 +207,7 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), not(containsString("X-HAPI-Response-Validation"))); + assertThat(status.toString(), not(containsString("X-FHIR-Response-Validation"))); } @Test @@ -212,6 +215,7 @@ public class ResponseValidatingInterceptorDstu21Test { IValidatorModule module = new FhirInstanceValidator(); myInterceptor.addValidatorModule(module); myInterceptor.setResponseHeaderValueNoIssues("No issues"); + myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION); HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata"); HttpResponse status = ourClient.execute(httpPost); @@ -223,7 +227,7 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.info("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), (containsString("X-HAPI-Response-Validation"))); + assertThat(status.toString(), (containsString("X-FHIR-Response-Validation"))); } @Test @@ -244,7 +248,7 @@ public class ResponseValidatingInterceptorDstu21Test { ourLog.trace("Response was:\n{}", responseContent); assertEquals(200, status.getStatusLine().getStatusCode()); - assertThat(status.toString(), not(containsString("X-HAPI-Response-Validation"))); + assertThat(status.toString(), not(containsString("X-FHIR-Response-Validation"))); } @AfterClass