From 58e6b7f6aa9074f0cee30f6dfa8490189e2e4a36 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Sat, 22 Jun 2019 16:03:35 -0400 Subject: [PATCH] Fix #1011 - Was resolved in #1355 --- .../ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java | 17 +++++++---------- .../fhir/jpa/dao/r4/FhirSystemDaoR4Test.java | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java index 1ecb5bb52e0..1c7799472e7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/BaseJpaR4Test.java @@ -36,9 +36,9 @@ import ca.uhn.fhir.validation.ValidationResult; import org.apache.commons.io.IOUtils; import org.hibernate.search.jpa.FullTextEntityManager; import org.hibernate.search.jpa.Search; -import org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.hapi.ctx.IValidationSupport; +import org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator; import org.hl7.fhir.r4.model.*; import org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent; import org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent; @@ -298,7 +298,6 @@ public abstract class BaseJpaR4Test extends BaseJpaTest { private JpaValidationSupportChainR4 myJpaValidationSupportChainR4; private PerformanceTracingLoggingInterceptor myPerformanceTracingLoggingInterceptor; private List mySystemInterceptors; - private FhirValidator myValidator; @After() public void afterCleanupDao() { @@ -392,13 +391,11 @@ public abstract class BaseJpaR4Test extends BaseJpaTest { } protected void validate(IBaseResource theResource) { - if (myValidator == null) { - myValidator = myFhirCtx.newValidator(); - FhirInstanceValidator validator = new FhirInstanceValidator(); - validator.setBestPracticeWarningLevel(IResourceValidator.BestPracticeWarningLevel.Ignore); - myValidator.registerValidatorModule(validator); - } - ValidationResult result = myValidator.validateWithResult(theResource); + FhirValidator validatorModule = myFhirCtx.newValidator(); + FhirInstanceValidator instanceValidator = new FhirInstanceValidator(myValidationSupport); + instanceValidator.setBestPracticeWarningLevel(IResourceValidator.BestPracticeWarningLevel.Ignore); + validatorModule.registerValidatorModule(instanceValidator); + ValidationResult result = validatorModule.validateWithResult(theResource); if (!result.isSuccessful()) { fail(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.toOperationOutcome())); } @@ -406,7 +403,7 @@ public abstract class BaseJpaR4Test extends BaseJpaTest { @AfterClass - public static void afterClassClearContextBaseJpaR4Test() throws Exception { + public static void afterClassClearContextBaseJpaR4Test() { ourValueSetDao.purgeCaches(); ourJpaValidationSupportChainR4.flush(); TestUtil.clearAllStaticFieldsForUnitTest(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java index c470a96e24b..c90ddea289e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java @@ -876,6 +876,22 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { validate(outcome); } + @Test + public void testBatchMissingUrlForPost() { + Bundle request = new Bundle(); + request.setType(BundleType.BATCH); + request + .addEntry() + .setResource(new Patient().setActive(true)) + .getRequest() + .setMethod(HTTPVerb.POST); + + Bundle outcome = mySystemDao.transaction(mySrd, request); + ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + assertEquals("201 Created", outcome.getEntry().get(0).getResponse().getStatus()); + validate(outcome); + } + @Test public void testTransactionCreateInlineMatchUrlWithOneMatch() {