diff options
| author | Paul-Christian Volkmer | 2025-11-21 12:29:05 +0100 |
|---|---|---|
| committer | GitHub | 2025-11-21 12:29:05 +0100 |
| commit | 2f8ccf33d108537ea7cfe398085a25a7bc926406 (patch) | |
| tree | 731fe307bccd37d8f20c46485ece8902f0c60e21 /src/test | |
| parent | 3e5949197c0a0a738321234746ab8e742389444c (diff) | |
feat: add alternative endpoints for request (#196)
This allows for requests to
(with optional path-prefix "/api"):
* POST /{usecase}
* POST /{usecase}/etl/patient-record => as DNPM:DIP
* DELETE /{usecase}/{ID}
* DELETE /{usecase}/etl/patient-record/{ID}
* DELETE /{usecase}/etl/patient/{ID} => as DNPM:DIP
Where {usecase} is one of:
* mtbfile
* mtb => as DNPM:DIP
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt | 69 | ||||
| -rw-r--r-- | src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt | 68 |
2 files changed, 103 insertions, 34 deletions
diff --git a/src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt index 95858f4..ce72ba3 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt @@ -25,6 +25,7 @@ import dev.dnpm.etl.processor.CustomMediaType import dev.dnpm.etl.processor.consent.ConsentEvaluation import dev.dnpm.etl.processor.consent.ConsentEvaluator import dev.dnpm.etl.processor.consent.TtpConsentStatus +import dev.dnpm.etl.processor.input.Dnpm21MtbFile.Companion.buildMtb import dev.dnpm.etl.processor.services.RequestProcessor import dev.pcvolkmer.mv64e.mtb.* import java.time.Instant @@ -36,6 +37,7 @@ import org.junit.jupiter.api.extension.ExtendWith import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsSource +import org.junit.jupiter.params.provider.ValueSource import org.mockito.Mock import org.mockito.Mockito.times import org.mockito.Mockito.verify @@ -112,6 +114,51 @@ class MtbFileRestControllerTest { } } + @ParameterizedTest + @ValueSource( + strings = + [ + "/mtbfile", + "/mtbfile/etl/patient-record", + "/mtb", + "/mtb/etl/patient-record", + "/api/mtbfile", + "/api/mtbfile/etl/patient-record", + "/api/mtb", + "/api/mtb/etl/patient-record", + ] + ) + fun shouldAcceptPostRequests(url: String) { + whenever(consentEvaluator.check(any<Mtb>())) + .thenReturn(ConsentEvaluation(TtpConsentStatus.BROAD_CONSENT_GIVEN, true)) + + val mtb = + buildMtb( + MvhMetadata.builder() + .modelProjectConsent( + ModelProjectConsent.builder() + .provisions( + listOf( + Provision.builder() + .date(Date()) + .type(ConsentProvision.PERMIT) + .purpose(ModelProjectConsentPurpose.SEQUENCING) + .build() + ) + ) + .build() + ) + .build() + ) + + mockMvc + .post(url) { + content = objectMapper.writeValueAsString(mtb) + contentType = CustomMediaType.APPLICATION_VND_DNPM_V2_MTB_JSON + } + .andExpect { status { isAccepted() } } + } + @Test fun shouldProcessDeleteRequest() { mockMvc.delete("/mtbfile/TEST_12345678").andExpect { status { isAccepted() } } @@ -123,6 +170,28 @@ class MtbFileRestControllerTest { ) verify(consentEvaluator, times(0)).check(any<Mtb>()) } + + @ParameterizedTest + @ValueSource( + strings = + [ + "/mtbfile/TEST_12345678", + "/mtbfile/etl/patient-record/TEST_12345678", + "/mtbfile/etl/patient/TEST_12345678", + "/mtb/TEST_12345678", + "/mtb/etl/patient-record/TEST_12345678", + "/mtb/etl/patient/TEST_12345678", + "/api/mtbfile/TEST_12345678", + "/api/mtbfile/etl/patient-record/TEST_12345678", + "/api/mtbfile/etl/patient/TEST_12345678", + "/api/mtb/TEST_12345678", + "/api/mtb/etl/patient-record/TEST_12345678", + "/api/mtb/etl/patient/TEST_12345678", + ] + ) + fun shouldAcceptDeleteRequests(url: String) { + mockMvc.delete(url).andExpect { status { isAccepted() } } + } } } diff --git a/src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt index 2b4cd34..84b081a 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt @@ -251,44 +251,44 @@ class ExtensionsTest { assertThat(mtbFile.diagnoses.first().id).isEqualTo(mtbFile.specimens.first().diagnosis.id) } - @Test - fun shouldNotThrowAnyExceptionOnMissingMsiId( - @Mock pseudonymizeService: PseudonymizeService - ) { + @Test + fun shouldNotThrowAnyExceptionOnMissingMsiId(@Mock pseudonymizeService: PseudonymizeService) { - doAnswer { - it.arguments[0] - "PSEUDO-ID" + doAnswer { + it.arguments[0] + "PSEUDO-ID" } - .whenever(pseudonymizeService) - .patientPseudonym(anyValueClass()) - - doAnswer { "TESTDOMAIN" }.whenever(pseudonymizeService).prefix() - - val mtbFile = - Mtb().apply { - this.patient = - Patient().apply { - this.id = "PID" - this.birthDate = Date.from(Instant.now()) - this.gender = GenderCoding().apply { this.code = GenderCodingCode.MALE } - } - this.msiFindings = listOf( - null, - Msi.builder().id("1").build(), - Msi.builder(). build(), - Msi.builder().specimen(null).build(), - Msi.builder().specimen(Reference.builder().build()).build() - ) - } + .whenever(pseudonymizeService) + .patientPseudonym(anyValueClass()) - mtbFile.pseudonymizeWith(pseudonymizeService) - mtbFile.anonymizeContentWith(pseudonymizeService) + doAnswer { "TESTDOMAIN" }.whenever(pseudonymizeService).prefix() - assertThat( mtbFile.msiFindings ).isNotNull - assertThat(mtbFile.msiFindings[1]).satisfiesAnyOf( + val mtbFile = + Mtb().apply { + this.patient = + Patient().apply { + this.id = "PID" + this.birthDate = Date.from(Instant.now()) + this.gender = GenderCoding().apply { this.code = GenderCodingCode.MALE } + } + this.msiFindings = + listOf( + null, + Msi.builder().id("1").build(), + Msi.builder().build(), + Msi.builder().specimen(null).build(), + Msi.builder().specimen(Reference.builder().build()).build(), + ) + } + + mtbFile.pseudonymizeWith(pseudonymizeService) + mtbFile.anonymizeContentWith(pseudonymizeService) + + assertThat(mtbFile.msiFindings).isNotNull + assertThat(mtbFile.msiFindings[1]) + .satisfiesAnyOf( { assertThat(it.id).isNull() }, - { assertThat(it.id).isEqualTo("TESTDOMAIN44e20a53bbbf9f3ae39626d05df7014dcd77d6098")} + { assertThat(it.id).isEqualTo("TESTDOMAIN44e20a53bbbf9f3ae39626d05df7014dcd77d6098") }, ) - } + } } |
