diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java index 38bd6934ea6..95f2368eabc 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java @@ -17,12 +17,16 @@ import org.hl7.fhir.dstu3.hapi.ctx.IValidationSupport.CodeValidationResult; import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus; import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; +import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent; +import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType; import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.dstu3.utils.FHIRPathEngine; import org.hl7.fhir.instance.model.api.IBaseResource; + import org.junit.*; import org.junit.rules.TestRule; import org.junit.rules.TestWatcher; @@ -737,6 +741,25 @@ public class FhirInstanceValidatorDstu3Test { assertThat(nonInfo, empty()); } + /** + * An invalid local reference should not cause a ServiceException. + */ + @Test + public void testInvalidLocalReference() { + Questionnaire resource = new Questionnaire(); + resource.setStatus(PublicationStatus.ACTIVE); + + QuestionnaireItemComponent item = new QuestionnaireItemComponent(); + item.setLinkId("linkId-1"); + item.setType(QuestionnaireItemType.CHOICE); + item.setOptions(new Reference("#invalid-ref")); + resource.addItem(item); + + ValidationResult output = myVal.validateWithResult(resource); + List nonInfo = logResultsAndReturnNonInformationalOnes(output); + assertThat(nonInfo, hasSize(2)); + } + /** * See #370 */