This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 035dfaa CAMEL-17337 - Resolve regression in FhirComponent (#6542) 035dfaa is described below commit 035dfaa1d9317e9547124fe16e015bbff92fce60 Author: Paul C <pau...@users.noreply.github.com> AuthorDate: Thu Dec 16 06:16:24 2021 +0000 CAMEL-17337 - Resolve regression in FhirComponent (#6542) Co-authored-by: Paul Coombes <paul.coom...@ouh.nhs.uk> --- components/camel-fhir/camel-fhir-component/pom.xml | 5 +++++ .../org/apache/camel/component/fhir/FhirComponent.java | 17 ----------------- .../camel/component/fhir/FhirConfigurationIT.java | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/components/camel-fhir/camel-fhir-component/pom.xml b/components/camel-fhir/camel-fhir-component/pom.xml index 4a8b935..903315a 100644 --- a/components/camel-fhir/camel-fhir-component/pom.xml +++ b/components/camel-fhir/camel-fhir-component/pom.xml @@ -114,6 +114,11 @@ <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.apache.camel</groupId> diff --git a/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java b/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java index b96a550..114dafd 100644 --- a/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java +++ b/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java @@ -33,9 +33,6 @@ import org.apache.camel.support.component.AbstractApiComponent; public class FhirComponent extends AbstractApiComponent<FhirApiName, FhirConfiguration, FhirApiCollection> { @Metadata(label = "advanced") - FhirConfiguration configuration; - - @Metadata(label = "advanced") private IGenericClient client; public FhirComponent() { @@ -74,18 +71,4 @@ public class FhirComponent extends AbstractApiComponent<FhirApiName, FhirConfigu } return result; } - - /** - * To use the shared configuration - */ - @Override - public void setConfiguration(FhirConfiguration configuration) { - super.setConfiguration(configuration); - } - - @Override - public FhirConfiguration getConfiguration() { - return super.getConfiguration(); - } - } diff --git a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirConfigurationIT.java b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirConfigurationIT.java index 433f68b..9fca464 100644 --- a/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirConfigurationIT.java +++ b/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirConfigurationIT.java @@ -20,6 +20,7 @@ import java.util.List; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.SummaryEnum; +import ca.uhn.fhir.rest.client.api.IClientInterceptor; import ca.uhn.fhir.rest.client.impl.GenericClient; import org.apache.camel.CamelContext; import org.apache.camel.ExtendedCamelContext; @@ -28,12 +29,17 @@ import org.apache.camel.component.fhir.internal.FhirApiCollection; import org.apache.camel.component.fhir.internal.FhirCreateApiMethod; import org.apache.camel.impl.DefaultCamelContext; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test class for {@link FhirConfiguration} APIs. */ +@ExtendWith(MockitoExtension.class) public class FhirConfigurationIT extends AbstractFhirTestSupport { private static final String PATH_PREFIX = FhirApiCollection.getCollection().getApiName(FhirCreateApiMethod.class).getName(); @@ -43,6 +49,9 @@ public class FhirConfigurationIT extends AbstractFhirTestSupport { + "&accessToken=token&serverUrl=http://localhost:8080/hapi-fhir-jpaserver-example/baseDstu3&fhirVersion=DSTU3"; private FhirConfiguration componentConfiguration; + @Mock + private IClientInterceptor mockClientInterceptor; + @Override protected CamelContext createCamelContext() throws Exception { final CamelContext context = new DefaultCamelContext(createCamelRegistry()); @@ -61,6 +70,9 @@ public class FhirConfigurationIT extends AbstractFhirTestSupport { fhirConfiguration.setServerUrl("http://localhost:8080/hapi-fhir-jpaserver-example/baseDstu3"); fhirConfiguration.setFhirVersion("DSTU3"); component.setConfiguration(fhirConfiguration); + + component.getClient(fhirConfiguration).registerInterceptor(this.mockClientInterceptor); + this.componentConfiguration = fhirConfiguration; context.addComponent("fhir", component); @@ -77,7 +89,9 @@ public class FhirConfigurationIT extends AbstractFhirTestSupport { assertEquals(EncodingEnum.JSON, client.getEncoding()); assertEquals(SummaryEnum.TEXT, client.getSummary()); List<Object> interceptors = client.getInterceptorService().getAllRegisteredInterceptors(); - assertEquals(5, interceptors.size()); + assertEquals(6, interceptors.size()); + + assertTrue(interceptors.contains(this.mockClientInterceptor), "User defined IClientInterceptor not found"); long counter = context.adapt(ExtendedCamelContext.class).getBeanIntrospection().getInvokedCounter(); assertEquals(0, counter, "Should not use reflection");