diff options
Diffstat (limited to 'src/test/kotlin')
3 files changed, 71 insertions, 65 deletions
diff --git a/src/test/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSenderTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSenderTest.kt index e5fb925..f1185ef 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSenderTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSenderTest.kt @@ -44,6 +44,8 @@ import org.springframework.kafka.core.KafkaTemplate import org.springframework.kafka.support.SendResult import org.springframework.retry.policy.SimpleRetryPolicy import org.springframework.retry.support.RetryTemplateBuilder +import java.time.Instant +import java.util.* import java.util.concurrent.CompletableFuture.completedFuture import java.util.concurrent.ExecutionException @@ -309,24 +311,28 @@ class KafkaMtbFileSenderTest { }.build() } - fun dnpmV2MtbFile(): Mtb = Mtb.builder() - .withPatient( - dev.pcvolkmer.mv64e.mtb.Patient.builder() - .withId("PID") - .withBirthDate("2000-08-08") - .withGender(CodingGender.builder().withCode(CodingGender.Code.MALE).build()) - .build() - ) - .withEpisodesOfCare( - listOf( - MTBEpisodeOfCare.builder() - .withId("1") - .withPatient(Reference("PID")) - .withPeriod(PeriodDate.builder().withStart("2023-08-08").build()) - .build() + fun dnpmV2MtbFile(): Mtb { + return Mtb().apply { + this.patient = dev.pcvolkmer.mv64e.mtb.Patient().apply { + this.id = "PID" + this.birthDate = Date.from(Instant.now()) + this.gender = GenderCoding().apply { + this.code = GenderCodingCode.MALE + } + } + this.episodesOfCare = listOf( + MtbEpisodeOfCare().apply { + this.id = "1" + this.patient = Reference().apply { + this.id = "PID" + } + this.period = PeriodDate().apply { + this.start = Date.from(Instant.now()) + } + } ) - ) - .build() + } + } fun bwhcV1kafkaRecordData(requestId: RequestId, consentStatus: Consent.Status): MtbRequest { return BwhcV1MtbFileRequest(requestId, bwhcV1MtbFile(consentStatus)) diff --git a/src/test/kotlin/dev/dnpm/etl/processor/output/RestDipMtbFileSenderTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/output/RestDipMtbFileSenderTest.kt index b35fb47..8395518 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/output/RestDipMtbFileSenderTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/output/RestDipMtbFileSenderTest.kt @@ -49,6 +49,8 @@ import org.springframework.test.web.client.MockRestServiceServer import org.springframework.test.web.client.match.MockRestRequestMatchers.* import org.springframework.test.web.client.response.MockRestResponseCreators.withStatus import org.springframework.web.client.RestTemplate +import java.time.Instant +import java.util.* class RestDipMtbFileSenderTest { @@ -155,7 +157,7 @@ class RestDipMtbFileSenderTest { withStatus(requestWithResponse.httpStatus).body(requestWithResponse.body).createResponse(it) } - val response = restMtbFileSender.send(DnpmV2MtbFileRequest(TEST_REQUEST_ID, dnpmV2MtbFile)) + val response = restMtbFileSender.send(DnpmV2MtbFileRequest(TEST_REQUEST_ID, dnpmV2MtbFile())) assertThat(response.status).isEqualTo(requestWithResponse.response.status) assertThat(response.body).isEqualTo(requestWithResponse.response.body) } @@ -267,24 +269,28 @@ class RestDipMtbFileSenderTest { ) .build() - val dnpmV2MtbFile: Mtb = Mtb.builder() - .withPatient( - dev.pcvolkmer.mv64e.mtb.Patient.builder() - .withId("PID") - .withBirthDate("2000-08-08") - .withGender(CodingGender.builder().withCode(CodingGender.Code.MALE).build()) - .build() - ) - .withEpisodesOfCare( - listOf( - MTBEpisodeOfCare.builder() - .withId("1") - .withPatient(Reference("PID")) - .withPeriod(PeriodDate.builder().withStart("2023-08-08").build()) - .build() + fun dnpmV2MtbFile(): Mtb { + return Mtb().apply { + this.patient = dev.pcvolkmer.mv64e.mtb.Patient().apply { + this.id = "PID" + this.birthDate = Date.from(Instant.now()) + this.gender = GenderCoding().apply { + this.code = GenderCodingCode.MALE + } + } + this.episodesOfCare = listOf( + MtbEpisodeOfCare().apply { + this.id = "1" + this.patient = Reference().apply { + this.id = "PID" + } + this.period = PeriodDate().apply { + this.start = Date.from(Instant.now()) + } + } ) - ) - .build() + } + } private const val ERROR_RESPONSE_BODY = "Sonstiger Fehler bei der Übertragung" 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 d0ccb2b..e30ee73 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/pseudonym/ExtensionsTest.kt @@ -21,10 +21,8 @@ package dev.dnpm.etl.processor.pseudonym import com.fasterxml.jackson.databind.ObjectMapper import de.ukw.ccc.bwhc.dto.* -import dev.pcvolkmer.mv64e.mtb.MTBEpisodeOfCare -import dev.pcvolkmer.mv64e.mtb.Mtb -import dev.pcvolkmer.mv64e.mtb.PeriodDate -import dev.pcvolkmer.mv64e.mtb.Reference +import de.ukw.ccc.bwhc.dto.Patient +import dev.pcvolkmer.mv64e.mtb.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test @@ -36,6 +34,8 @@ import org.mockito.kotlin.anyValueClass import org.mockito.kotlin.doAnswer import org.mockito.kotlin.whenever import org.springframework.core.io.ClassPathResource +import java.time.Instant +import java.util.* @ExtendWith(MockitoExtension::class) class ExtensionsTest { @@ -207,7 +207,7 @@ class ExtensionsTest { inner class UsingDnpmV2Datamodel { val FAKE_MTB_FILE_PATH = "mv64e-mtb-fake-patient.json" - val CLEAN_PATIENT_ID = "63f8fd7b-8127-4f3c-8843-aa9199e21c29" + val CLEAN_PATIENT_ID = "e14bf9b6-7982-4933-a648-cfdea6484f1c" private fun fakeMtbFile(): Mtb { val mtbFile = ClassPathResource(FAKE_MTB_FILE_PATH).inputStream @@ -244,32 +244,26 @@ class ExtensionsTest { "TESTDOMAIN" }.whenever(pseudonymizeService).prefix() - val mtbFile = Mtb.builder() - .withPatient( - dev.pcvolkmer.mv64e.mtb.Patient.builder() - .withId("1") - .withBirthDate("2000-08-08") - .withGender(null) - .build() + val mtbFile = Mtb().apply { + this.patient = dev.pcvolkmer.mv64e.mtb.Patient().apply { + this.id = "PID" + this.birthDate = Date.from(Instant.now()) + this.gender = GenderCoding().apply { + this.code = GenderCodingCode.MALE + } + } + this.episodesOfCare = listOf( + MtbEpisodeOfCare().apply { + this.id = "1" + this.patient = Reference().apply { + this.id = "PID" + } + this.period = PeriodDate().apply { + this.start = Date.from(Instant.now()) + } + } ) - .withEpisodesOfCare( - listOf( - MTBEpisodeOfCare.builder() - .withId("1") - .withPatient(Reference("1")) - .withPeriod(PeriodDate.builder().withStart("2023-08-08").build()) - .build() - ) - ) - .withClaims(null) - .withDiagnoses(null) - .withCarePlans(null) - .withClaimResponses(null) - .withHistologyReports(null) - .withNgsReports(null) - .withResponses(null) - .withSpecimens(null) - .build() + } mtbFile.pseudonymizeWith(pseudonymizeService) mtbFile.anonymizeContentWith(pseudonymizeService) |
