summaryrefslogtreecommitdiff
path: root/src/test/kotlin/dev
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2025-04-04 14:34:31 +0200
committerGitHub2025-04-04 14:34:31 +0200
commit7ae34719fd0e34d7065c5a8eb4ccd58efc2370d8 (patch)
tree9d5933db3e5879e886dd28cb887941f869f7c168 /src/test/kotlin/dev
parent033750eb1015ebc4d1612858dff54496e64a3410 (diff)
feat: add new MTB endpoint path (#93)
Diffstat (limited to 'src/test/kotlin/dev')
-rw-r--r--src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt180
1 files changed, 109 insertions, 71 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 3e5b53a..ade27b4 100644
--- a/src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt
+++ b/src/test/kotlin/dev/dnpm/etl/processor/input/MtbFileRestControllerTest.kt
@@ -1,7 +1,7 @@
/*
* This file is part of ETL-Processor
*
- * Copyright (c) 2024 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
+ * Copyright (c) 2025 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import de.ukw.ccc.bwhc.dto.*
import dev.dnpm.etl.processor.services.RequestProcessor
import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mock
@@ -40,62 +41,122 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders
@ExtendWith(MockitoExtension::class)
class MtbFileRestControllerTest {
- private lateinit var mockMvc: MockMvc
+ private val objectMapper = ObjectMapper()
- private lateinit var requestProcessor: RequestProcessor
+ @Nested
+ inner class BwhcRequests {
- private val objectMapper = ObjectMapper()
+ private lateinit var mockMvc: MockMvc
+
+ private lateinit var requestProcessor: RequestProcessor
+
+ @BeforeEach
+ fun setup(
+ @Mock requestProcessor: RequestProcessor
+ ) {
+ this.requestProcessor = requestProcessor
+ val controller = MtbFileRestController(requestProcessor)
+ this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
+ }
+
+ @Test
+ fun shouldProcessPostRequest() {
+ mockMvc.post("/mtbfile") {
+ content = objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.ACTIVE))
+ contentType = MediaType.APPLICATION_JSON
+ }.andExpect {
+ status {
+ isAccepted()
+ }
+ }
+
+ verify(requestProcessor, times(1)).processMtbFile(any())
+ }
+
+ @Test
+ fun shouldProcessPostRequestWithRejectedConsent() {
+ mockMvc.post("/mtbfile") {
+ content = objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.REJECTED))
+ contentType = MediaType.APPLICATION_JSON
+ }.andExpect {
+ status {
+ isAccepted()
+ }
+ }
+
+ verify(requestProcessor, times(1)).processDeletion(anyValueClass())
+ }
+
+ @Test
+ fun shouldProcessDeleteRequest() {
+ mockMvc.delete("/mtbfile/TEST_12345678").andExpect {
+ status {
+ isAccepted()
+ }
+ }
- @BeforeEach
- fun setup(
- @Mock requestProcessor: RequestProcessor
- ) {
- this.requestProcessor = requestProcessor
- val controller = MtbFileRestController(requestProcessor)
- this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
+ verify(requestProcessor, times(1)).processDeletion(anyValueClass())
+ }
}
- @Test
- fun shouldProcessMtbFilePostRequest() {
- val mtbFile = MtbFile.builder()
- .withPatient(
- Patient.builder()
- .withId("TEST_12345678")
- .withBirthDate("2000-08-08")
- .withGender(Patient.Gender.MALE)
- .build()
- )
- .withConsent(
- Consent.builder()
- .withId("1")
- .withStatus(Consent.Status.ACTIVE)
- .withPatient("TEST_12345678")
- .build()
- )
- .withEpisode(
- Episode.builder()
- .withId("1")
- .withPatient("TEST_12345678")
- .withPeriod(PeriodStart("2023-08-08"))
- .build()
- )
- .build()
+ @Nested
+ inner class BwhcRequestsWithAlias {
+
+ private lateinit var mockMvc: MockMvc
- mockMvc.post("/mtbfile") {
- content = objectMapper.writeValueAsString(mtbFile)
- contentType = MediaType.APPLICATION_JSON
- }.andExpect {
- status {
- isAccepted()
+ private lateinit var requestProcessor: RequestProcessor
+
+ @BeforeEach
+ fun setup(
+ @Mock requestProcessor: RequestProcessor
+ ) {
+ this.requestProcessor = requestProcessor
+ val controller = MtbFileRestController(requestProcessor)
+ this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
+ }
+
+ @Test
+ fun shouldProcessPostRequest() {
+ mockMvc.post("/mtb") {
+ content = objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.ACTIVE))
+ contentType = MediaType.APPLICATION_JSON
+ }.andExpect {
+ status {
+ isAccepted()
+ }
}
+
+ verify(requestProcessor, times(1)).processMtbFile(any())
}
- verify(requestProcessor, times(1)).processMtbFile(any())
+ @Test
+ fun shouldProcessPostRequestWithRejectedConsent() {
+ mockMvc.post("/mtb") {
+ content = objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.REJECTED))
+ contentType = MediaType.APPLICATION_JSON
+ }.andExpect {
+ status {
+ isAccepted()
+ }
+ }
+
+ verify(requestProcessor, times(1)).processDeletion(anyValueClass())
+ }
+
+ @Test
+ fun shouldProcessDeleteRequest() {
+ mockMvc.delete("/mtb/TEST_12345678").andExpect {
+ status {
+ isAccepted()
+ }
+ }
+
+ verify(requestProcessor, times(1)).processDeletion(anyValueClass())
+ }
}
- @Test
- fun shouldProcessMtbFilePostRequestWithRejectedConsent() {
- val mtbFile = MtbFile.builder()
+ companion object {
+ fun bwhcMtbFileContent(consentStatus: Consent.Status) = MtbFile.builder()
.withPatient(
Patient.builder()
.withId("TEST_12345678")
@@ -106,7 +167,7 @@ class MtbFileRestControllerTest {
.withConsent(
Consent.builder()
.withId("1")
- .withStatus(Consent.Status.REJECTED)
+ .withStatus(consentStatus)
.withPatient("TEST_12345678")
.build()
)
@@ -118,28 +179,5 @@ class MtbFileRestControllerTest {
.build()
)
.build()
-
- mockMvc.post("/mtbfile") {
- content = objectMapper.writeValueAsString(mtbFile)
- contentType = MediaType.APPLICATION_JSON
- }.andExpect {
- status {
- isAccepted()
- }
- }
-
- verify(requestProcessor, times(1)).processDeletion(anyValueClass())
}
-
- @Test
- fun shouldProcessMtbFileDeleteRequest() {
- mockMvc.delete("/mtbfile/TEST_12345678").andExpect {
- status {
- isAccepted()
- }
- }
-
- verify(requestProcessor, times(1)).processDeletion(anyValueClass())
- }
-
-} \ No newline at end of file
+}