From 75b08c9d5e366ad83ef0432ae5e4f657ac165d26 Mon Sep 17 00:00:00 2001 From: James Netherton Date: Mon, 9 Sep 2024 17:00:28 +0100 Subject: [PATCH] Fix paths to FHIR DSTU_2_1 & DSTU3 properties files Fixes #6441 --- extensions/fhir/deployment/pom.xml | 6 +++ .../dstu2_1/FhirDstu2_1Processor.java | 2 +- .../deployment/dstu3/FhirDstu3Processor.java | 2 +- .../component/fhir/FhirConfigurationTest.java | 53 +++++++++++++++++++ .../component/fhir/it/FhirTestResource.java | 8 ++- 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 extensions/fhir/deployment/src/test/java/org/apache/camel/quarkus/component/fhir/FhirConfigurationTest.java diff --git a/extensions/fhir/deployment/pom.xml b/extensions/fhir/deployment/pom.xml index 05598a5e41a4..12926b921495 100644 --- a/extensions/fhir/deployment/pom.xml +++ b/extensions/fhir/deployment/pom.xml @@ -50,6 +50,12 @@ org.apache.camel.quarkus camel-quarkus-fhir + + + io.quarkus + quarkus-junit5-internal + test + diff --git a/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu2_1/FhirDstu2_1Processor.java b/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu2_1/FhirDstu2_1Processor.java index 2c340858bd69..ed34dfa6a9c2 100644 --- a/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu2_1/FhirDstu2_1Processor.java +++ b/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu2_1/FhirDstu2_1Processor.java @@ -43,7 +43,7 @@ public class FhirDstu2_1Processor { - private static final String FHIR_VERSION_PROPERTIES = "org/hl7/fhir/dstu2016may/model/fhirversion.properties"; + private static final String FHIR_VERSION_PROPERTIES = "org/hl7/fhir/dstu2016may/hapi/model/fhirversion.properties"; @BuildStep(onlyIf = FhirFlags.Dstu2_1Enabled.class) Dstu2_1PropertiesBuildItem fhirProperties() { diff --git a/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu3/FhirDstu3Processor.java b/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu3/FhirDstu3Processor.java index ba7d0ae8c145..d9e93841081f 100644 --- a/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu3/FhirDstu3Processor.java +++ b/extensions/fhir/deployment/src/main/java/org/apache/camel/quarkus/component/fhir/deployment/dstu3/FhirDstu3Processor.java @@ -43,7 +43,7 @@ import static org.apache.camel.quarkus.component.fhir.deployment.FhirUtil.getResourceDefinitions; public class FhirDstu3Processor { - private static final String FHIR_VERSION_PROPERTIES = "org/hl7/fhir/dstu3/model/fhirversion.properties"; + private static final String FHIR_VERSION_PROPERTIES = "org/hl7/fhir/dstu3/hapi/model/fhirversion.properties"; @BuildStep(onlyIf = FhirFlags.Dstu3Enabled.class) Dstu3PropertiesBuildItem fhirProperties() { diff --git a/extensions/fhir/deployment/src/test/java/org/apache/camel/quarkus/component/fhir/FhirConfigurationTest.java b/extensions/fhir/deployment/src/test/java/org/apache/camel/quarkus/component/fhir/FhirConfigurationTest.java new file mode 100644 index 000000000000..e8a72100df74 --- /dev/null +++ b/extensions/fhir/deployment/src/test/java/org/apache/camel/quarkus/component/fhir/FhirConfigurationTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.fhir; + +import io.quarkus.arc.Arc; +import io.quarkus.arc.InjectableBean; +import io.quarkus.test.QuarkusUnitTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +class FhirConfigurationTest { + + @RegisterExtension + static final QuarkusUnitTest CONFIG = new QuarkusUnitTest() + .overrideConfigKey("quarkus.camel.fhir.enable-dstu2", "true") + .overrideConfigKey("quarkus.camel.fhir.enable-dstu2_hl7org", "true") + .overrideConfigKey("quarkus.camel.fhir.enable-dstu2_1", "true") + .overrideConfigKey("quarkus.camel.fhir.enable-dstu3", "true") + .overrideConfigKey("quarkus.camel.fhir.enable-r4", "true") + .overrideConfigKey("quarkus.camel.fhir.enable-r5", "true") + .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); + + @Test + void allModelsEnabled() { + Assertions.assertNotNull(getFhirContextBean("DSTU2")); + Assertions.assertNotNull(getFhirContextBean("DSTU2_1")); + Assertions.assertNotNull(getFhirContextBean("DSTU2_HL7ORG")); + Assertions.assertNotNull(getFhirContextBean("DSTU3")); + Assertions.assertNotNull(getFhirContextBean("R4")); + Assertions.assertNotNull(getFhirContextBean("R5")); + } + + private InjectableBean getFhirContextBean(String beanName) { + return Arc.container().namedBean(beanName); + } +} diff --git a/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTestResource.java b/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTestResource.java index 39db3174f5bc..670d6fb5992e 100644 --- a/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTestResource.java +++ b/integration-tests/fhir/src/test/java/org/apache/camel/quarkus/component/fhir/it/FhirTestResource.java @@ -56,6 +56,12 @@ public Map start() { return Collections.emptyMap(); } + if (this.fhirVersion.equals(FhirVersion.DSTU2_1)) { + // TODO: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/issues/335 + // Return a fictional host to allow the application to start, which allows a minimal check that native mode can work + return Map.of(String.format("camel.fhir.%s.test-url", fhirVersion.simpleVersion()), "http://localhost:8080"); + } + try { LOGGER.info("FHIR version {} is enabled. Starting hapi test container for it.", fhirVersion.simpleVersion()); String imageName = fhirVersion.getContainerImageName(); @@ -127,7 +133,7 @@ public String getContextPath() { public String getContainerImageName() { String imageProperty = "fhir.container.image"; if (name().contains("DSTU")) { - imageProperty = "fhir-dstu.container-image"; + imageProperty = "fhir-dstu.container.image"; } return ConfigProvider.getConfig().getValue(imageProperty, String.class); }