summaryrefslogtreecommitdiff
path: root/src/test/java/dev/dnpm/etl
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2026-09-07 09:23:53 +0200
committerGitHub2026-09-07 07:23:53 +0000
commita0b85ed6a990e8cf533be4ace3b1fabb5ad14d6f (patch)
treea2446afa7d62bf3157b542d138e68c484873d345 /src/test/java/dev/dnpm/etl
parent26edfd897f0a65d252ebf74f1b4f33cba0742643 (diff)
feat: fail early on invalid gICS HTTP(S) URI (#316)
Diffstat (limited to 'src/test/java/dev/dnpm/etl')
-rw-r--r--src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java b/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java
index 1f9e698..90c0734 100644
--- a/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java
+++ b/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java
@@ -22,6 +22,7 @@ package dev.dnpm.etl.processor.consent;
import static dev.dnpm.etl.processor.consent.GicsConsentService.IS_CONSENTED_ENDPOINT;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withServerError;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@@ -44,7 +45,10 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueType;
import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent;
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.restclient.test.autoconfigure.RestClientTest;
import org.springframework.http.MediaType;
@@ -257,4 +261,27 @@ class GicsConsentServiceTest {
assertThat(fhirJsonParser.encodeToString(actual)).isEqualTo(miiConsent);
}
+
+ @Nested
+ static class WithoutValidConfig {
+
+ @ParameterizedTest
+ @ValueSource(strings = {"", "mailto:test@example.com", "ftp://localhost"})
+ void shouldNotUseGicsConsentServiceWithoutGicsUri(String uri) throws Exception {
+ final var testConfigProperties =
+ new GIcsConfigProperties(uri, null, null, "", "", null, "", "", "", "", "", "");
+
+ final var exception =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new GicsConsentService(
+ testConfigProperties,
+ RetryTemplate.builder().maxAttempts(1).build(),
+ new RestTemplate(),
+ new AppFhirConfig()));
+
+ assertThat(exception.getMessage()).isEqualTo("gICS URI must be a valid URI in configuration");
+ }
+ }
}