mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-25 01:18:37 +00:00
Merge pull request #874 from hdconradi/validation-server-exception-when-local-reference-absent
Validation server exception when local reference absent
This commit is contained in:
commit
eb77b8a225
@ -1575,9 +1575,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||
|
||||
if (pol.checkExists()) {
|
||||
if (we == null) {
|
||||
if (fetcher == null)
|
||||
throw new FHIRException("Resource resolution services not provided");
|
||||
we = fetcher.fetch(hostContext.appContext, ref);
|
||||
if (fetcher == null) {
|
||||
if (!refType.equals("contained"))
|
||||
throw new FHIRException("Resource resolution services not provided");
|
||||
} else {
|
||||
we = fetcher.fetch(hostContext.appContext, ref);
|
||||
}
|
||||
}
|
||||
rule(errors, IssueType.STRUCTURE, element.line(), element.col(), path, we != null, "Unable to resolve resource '"+ref+"'");
|
||||
}
|
||||
|
@ -18,12 +18,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;
|
||||
@ -760,6 +764,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<SingleValidationMessage> nonInfo = logResultsAndReturnNonInformationalOnes(output);
|
||||
assertThat(nonInfo, hasSize(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* See #370
|
||||
*/
|
||||
|
@ -70,6 +70,21 @@ public class FhirInstanceValidatorR4Test {
|
||||
myValidConcepts.add(theSystem + "___" + theCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* An invalid local reference should not cause a ServiceException.
|
||||
*/
|
||||
@Test
|
||||
public void testInvalidLocalReference() {
|
||||
QuestionnaireResponse resource = new QuestionnaireResponse();
|
||||
resource.setStatus(QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED);
|
||||
|
||||
resource.setSubject(new Reference("#invalid-ref"));
|
||||
|
||||
ValidationResult output = myVal.validateWithResult(resource);
|
||||
List<SingleValidationMessage> nonInfo = logResultsAndReturnNonInformationalOnes(output);
|
||||
assertThat(nonInfo, hasSize(2));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
public void before() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user