From 07852800b1151280c7074207a744d83f9f967bb6 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 12 Nov 2019 22:25:06 -0500 Subject: [PATCH] Resolve test issues --- pom.xml | 12 --------- .../fhir/jpa/starter/JpaRestfulServer.java | 19 +++++++++++-- .../fhir/jpa/starter/ExampleServerR5IT.java | 27 +++++++++++++------ 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index d24f847..c27bfc9 100644 --- a/pom.xml +++ b/pom.xml @@ -74,18 +74,6 @@ - - ca.uhn.hapi.fhir - hapi-fhir-jpaserver-elasticsearch - ${project.version} - - - commons-logging - commons-logging - - - - ca.uhn.hapi.fhir diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java index 9f88f5e..ce7cf55 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/JpaRestfulServer.java @@ -5,11 +5,16 @@ import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor; +import ca.uhn.fhir.jpa.bulk.BulkDataExportProvider; import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.DaoRegistry; import ca.uhn.fhir.jpa.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; -import ca.uhn.fhir.jpa.provider.*; +import ca.uhn.fhir.jpa.provider.GraphQLProvider; +import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2; +import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2; +import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; +import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3; import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; import ca.uhn.fhir.jpa.provider.r4.JpaConformanceProviderR4; @@ -24,7 +29,11 @@ import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy; import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.rest.server.interceptor.*; +import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor; +import ca.uhn.fhir.rest.server.interceptor.LoggingInterceptor; +import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; +import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; +import ca.uhn.fhir.rest.server.interceptor.ResponseValidatingInterceptor; import ca.uhn.fhir.validation.IValidatorModule; import ca.uhn.fhir.validation.ResultSeverityEnum; import org.hl7.fhir.dstu3.model.Bundle; @@ -257,6 +266,9 @@ public class JpaRestfulServer extends RestfulServer { // Validation IValidatorModule validatorModule; switch (fhirVersion) { + case DSTU2: + validatorModule = appCtx.getBean("myInstanceValidatorDstu2", IValidatorModule.class); + break; case DSTU3: validatorModule = appCtx.getBean("myInstanceValidatorDstu3", IValidatorModule.class); break; @@ -266,6 +278,9 @@ public class JpaRestfulServer extends RestfulServer { case R5: validatorModule = appCtx.getBean("myInstanceValidatorR5", IValidatorModule.class); break; + // These versions are not supported by HAPI FHIR JPA + case DSTU2_HL7ORG: + case DSTU2_1: default: validatorModule = null; break; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java index 04aee05..7eff8b0 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java @@ -14,10 +14,12 @@ import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Observation; -import org.hl7.fhir.r4.model.Patient; -import org.hl7.fhir.r4.model.Subscription; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.Observation; +import org.hl7.fhir.r5.model.Patient; +import org.hl7.fhir.r5.model.Subscription; +import org.hl7.fhir.r5.model.Topic; +import org.hl7.fhir.r5.model.codesystems.SubscriptionChannelType; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -43,7 +45,7 @@ public class ExampleServerR5IT { HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:h2:mem:dbr5"); HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R5"); HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true"); - ourCtx = FhirContext.forR4(); + ourCtx = FhirContext.forR5(); } @Test @@ -61,17 +63,26 @@ public class ExampleServerR5IT { @Test public void testWebsocketSubscription() throws Exception { + + /* + * Create topic + */ + Topic topic = new Topic(); + topic.getResourceTrigger().getQueryCriteria().setCurrent("Observation?status=final"); + /* * Create subscription */ Subscription subscription = new Subscription(); + subscription.getTopic().setResource(topic); subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)"); subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED); - subscription.setCriteria("Observation?status=final"); Subscription.SubscriptionChannelComponent channel = new Subscription.SubscriptionChannelComponent(); - channel.setType(Subscription.SubscriptionChannelType.WEBSOCKET); - channel.setPayload("application/json"); + channel.getType().addCoding() + .setSystem(SubscriptionChannelType.WEBSOCKET.getSystem()) + .setCode(SubscriptionChannelType.WEBSOCKET.toCode()); + channel.getPayload().setContentType("application/json"); subscription.setChannel(channel); MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();