From 5fcc24f915f0e91106b5890e81854720e9ead1a4 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 29 Apr 2024 10:11:25 +0200 Subject: refactor: add additional constructors --- .../etl/processor/services/RequestProcessorTest.kt | 68 +++++---- .../etl/processor/services/RequestServiceTest.kt | 158 ++++++++++----------- 2 files changed, 112 insertions(+), 114 deletions(-) (limited to 'src/test/kotlin/dev') diff --git a/src/test/kotlin/dev/dnpm/etl/processor/services/RequestProcessorTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/services/RequestProcessorTest.kt index 611c0ff..c82bccd 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/services/RequestProcessorTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/services/RequestProcessorTest.kt @@ -22,9 +22,7 @@ package dev.dnpm.etl.processor.services import com.fasterxml.jackson.databind.ObjectMapper import de.ukw.ccc.bwhc.dto.* import dev.dnpm.etl.processor.config.AppConfigProperties -import dev.dnpm.etl.processor.monitoring.Request -import dev.dnpm.etl.processor.monitoring.RequestStatus -import dev.dnpm.etl.processor.monitoring.RequestType +import dev.dnpm.etl.processor.monitoring.* import dev.dnpm.etl.processor.output.MtbFileSender import dev.dnpm.etl.processor.output.RestMtbFileSender import dev.dnpm.etl.processor.pseudonym.PseudonymizeService @@ -88,14 +86,14 @@ class RequestProcessorTest { fun testShouldSendMtbFileDuplicationAndSaveUnknownRequestStatusAtFirst() { doAnswer { Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "zdlzv5s5ydmd4ktw2v5piohegc4jcyrm6j66bq6tv2uxuerndmga", - type = RequestType.MTB_FILE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-08-08T02:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "zdlzv5s5ydmd4ktw2v5piohegc4jcyrm6j66bq6tv2uxuerndmga", + RequestType.MTB_FILE, + RequestStatus.SUCCESS, + Instant.parse("2023-08-08T02:00:00Z") ) }.`when`(requestService).lastMtbFileRequestForPatientPseudonym(anyString()) @@ -147,14 +145,14 @@ class RequestProcessorTest { fun testShouldDetectMtbFileDuplicationAndSendDuplicationEvent() { doAnswer { Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "zdlzv5s5ydmd4ktw2v5piohegc4jcyrm6j66bq6tv2uxuerndmga", - type = RequestType.MTB_FILE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-08-08T02:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "zdlzv5s5ydmd4ktw2v5piohegc4jcyrm6j66bq6tv2uxuerndmga", + RequestType.MTB_FILE, + RequestStatus.SUCCESS, + Instant.parse("2023-08-08T02:00:00Z") ) }.`when`(requestService).lastMtbFileRequestForPatientPseudonym(anyString()) @@ -206,14 +204,14 @@ class RequestProcessorTest { fun testShouldSendMtbFileAndSendSuccessEvent() { doAnswer { Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "different", - type = RequestType.MTB_FILE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-08-08T02:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "different", + RequestType.MTB_FILE, + RequestStatus.SUCCESS, + Instant.parse("2023-08-08T02:00:00Z") ) }.`when`(requestService).lastMtbFileRequestForPatientPseudonym(anyString()) @@ -269,14 +267,14 @@ class RequestProcessorTest { fun testShouldSendMtbFileAndSendErrorEvent() { doAnswer { Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "different", - type = RequestType.MTB_FILE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-08-08T02:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "different", + RequestType.MTB_FILE, + RequestStatus.SUCCESS, + Instant.parse("2023-08-08T02:00:00Z") ) }.`when`(requestService).lastMtbFileRequestForPatientPseudonym(anyString()) diff --git a/src/test/kotlin/dev/dnpm/etl/processor/services/RequestServiceTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/services/RequestServiceTest.kt index 3cf8804..02cd2cf 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/services/RequestServiceTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/services/RequestServiceTest.kt @@ -41,14 +41,14 @@ class RequestServiceTest { private lateinit var requestService: RequestService private fun anyRequest() = any(Request::class.java) ?: Request( - id = 0L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_dummy", - pid = "PX", - fingerprint = "dummy", - type = RequestType.MTB_FILE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-08-08T02:00:00Z") + 0L, + UUID.randomUUID().toString(), + "TEST_dummy", + "PX", + "dummy", + RequestType.MTB_FILE, + RequestStatus.SUCCESS, + Instant.parse("2023-08-08T02:00:00Z") ) @BeforeEach @@ -63,34 +63,34 @@ class RequestServiceTest { fun shouldIndicateLastRequestIsDeleteRequest() { val requests = listOf( Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.MTB_FILE, - status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-07-07T00:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.MTB_FILE, + RequestStatus.WARNING, + Instant.parse("2023-07-07T00:00:00Z") ), Request( - id = 2L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdefd", - type = RequestType.DELETE, - status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-07-07T02:00:00Z") + 2L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdefd", + RequestType.DELETE, + RequestStatus.WARNING, + Instant.parse("2023-07-07T02:00:00Z") ), Request( - id = 3L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.MTB_FILE, - status = RequestStatus.UNKNOWN, - processedAt = Instant.parse("2023-08-11T00:00:00Z") + 3L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.MTB_FILE, + RequestStatus.UNKNOWN, + Instant.parse("2023-08-11T00:00:00Z") ) ) @@ -103,34 +103,34 @@ class RequestServiceTest { fun shouldIndicateLastRequestIsNotDeleteRequest() { val requests = listOf( Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.MTB_FILE, - status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-07-07T00:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.MTB_FILE, + RequestStatus.WARNING, + Instant.parse("2023-07-07T00:00:00Z") ), Request( - id = 2L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.MTB_FILE, - status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-07-07T02:00:00Z") + 2L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.MTB_FILE, + RequestStatus.WARNING, + Instant.parse("2023-07-07T02:00:00Z") ), Request( - id = 3L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.MTB_FILE, - status = RequestStatus.UNKNOWN, - processedAt = Instant.parse("2023-08-11T00:00:00Z") + 3L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.MTB_FILE, + RequestStatus.UNKNOWN, + Instant.parse("2023-08-11T00:00:00Z") ) ) @@ -143,24 +143,24 @@ class RequestServiceTest { fun shouldReturnPatientsLastRequest() { val requests = listOf( Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.DELETE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-07-07T02:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.DELETE, + RequestStatus.SUCCESS, + Instant.parse("2023-07-07T02:00:00Z") ), Request( - id = 1L, - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678902", - pid = "P2", - fingerprint = "0123456789abcdef2", - type = RequestType.MTB_FILE, - status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-08-08T00:00:00Z") + 1L, + UUID.randomUUID().toString(), + "TEST_12345678902", + "P2", + "0123456789abcdef2", + RequestType.MTB_FILE, + RequestStatus.WARNING, + Instant.parse("2023-08-08T00:00:00Z") ) ) @@ -187,13 +187,13 @@ class RequestServiceTest { }.`when`(requestRepository).save(anyRequest()) val request = Request( - uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678901", - pid = "P1", - fingerprint = "0123456789abcdef1", - type = RequestType.DELETE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-07-07T02:00:00Z") + UUID.randomUUID().toString(), + "TEST_12345678901", + "P1", + "0123456789abcdef1", + RequestType.DELETE, + RequestStatus.SUCCESS, + Instant.parse("2023-07-07T02:00:00Z") ) requestService.save(request) -- cgit v1.2.3