From 6ecb439007b4fa6dec9af1e0334b89fd235a97be Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Fri, 11 Aug 2023 09:22:54 +0200 Subject: Issue #3: Detect the request type of request with last known status (#5) --- .../etl/processor/services/RequestProcessorTest.kt | 8 +-- .../etl/processor/services/RequestServiceTest.kt | 58 +++++++++++++++------- 2 files changed, 43 insertions(+), 23 deletions(-) (limited to 'src/test/kotlin/dev/dnpm') 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 f9d8182..7856833 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/services/RequestProcessorTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/services/RequestProcessorTest.kt @@ -92,7 +92,7 @@ class RequestProcessorTest { doAnswer { false - }.`when`(requestService).isLastRequestDeletion(anyString()) + }.`when`(requestService).isLastRequestWithKnownStatusDeletion(anyString()) doAnswer { it.arguments[0] as String @@ -147,7 +147,7 @@ class RequestProcessorTest { doAnswer { false - }.`when`(requestService).isLastRequestDeletion(anyString()) + }.`when`(requestService).isLastRequestWithKnownStatusDeletion(anyString()) doAnswer { it.arguments[0] as String @@ -202,7 +202,7 @@ class RequestProcessorTest { doAnswer { false - }.`when`(requestService).isLastRequestDeletion(anyString()) + }.`when`(requestService).isLastRequestWithKnownStatusDeletion(anyString()) doAnswer { MtbFileSender.Response(status = RequestStatus.SUCCESS) @@ -261,7 +261,7 @@ class RequestProcessorTest { doAnswer { false - }.`when`(requestService).isLastRequestDeletion(anyString()) + }.`when`(requestService).isLastRequestWithKnownStatusDeletion(anyString()) doAnswer { MtbFileSender.Response(status = RequestStatus.ERROR) 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 3e0a979..3cf8804 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/services/RequestServiceTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/services/RequestServiceTest.kt @@ -68,23 +68,33 @@ class RequestServiceTest { patientId = "TEST_12345678901", pid = "P1", fingerprint = "0123456789abcdef1", + type = RequestType.MTB_FILE, + status = RequestStatus.WARNING, + processedAt = 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.SUCCESS, - processedAt = Instant.parse("2023-08-08T02:00:00Z") + status = RequestStatus.WARNING, + processedAt = Instant.parse("2023-07-07T02:00:00Z") ), Request( - id = 1L, + id = 3L, uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678902", - pid = "P2", - fingerprint = "0123456789abcdef2", + patientId = "TEST_12345678901", + pid = "P1", + fingerprint = "0123456789abcdef1", type = RequestType.MTB_FILE, - status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-08-08T00:00:00Z") + status = RequestStatus.UNKNOWN, + processedAt = Instant.parse("2023-08-11T00:00:00Z") ) ) - val actual = RequestService.isLastRequestDeletion(requests) + val actual = RequestService.isLastRequestWithKnownStatusDeletion(requests) assertThat(actual).isTrue() } @@ -98,23 +108,33 @@ class RequestServiceTest { patientId = "TEST_12345678901", pid = "P1", fingerprint = "0123456789abcdef1", - type = RequestType.DELETE, - status = RequestStatus.SUCCESS, - processedAt = Instant.parse("2023-07-07T02:00:00Z") + type = RequestType.MTB_FILE, + status = RequestStatus.WARNING, + processedAt = Instant.parse("2023-07-07T00:00:00Z") ), Request( - id = 1L, + id = 2L, uuid = UUID.randomUUID().toString(), - patientId = "TEST_12345678902", - pid = "P2", - fingerprint = "0123456789abcdef2", + patientId = "TEST_12345678901", + pid = "P1", + fingerprint = "0123456789abcdef1", type = RequestType.MTB_FILE, status = RequestStatus.WARNING, - processedAt = Instant.parse("2023-08-08T00:00:00Z") + processedAt = 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") ) ) - val actual = RequestService.isLastRequestDeletion(requests) + val actual = RequestService.isLastRequestWithKnownStatusDeletion(requests) assertThat(actual).isFalse() } @@ -197,7 +217,7 @@ class RequestServiceTest { @Test fun isLastRequestDeletionShouldRequestAllRequestsForPatientPseudonym() { - requestService.isLastRequestDeletion("TEST_12345678901") + requestService.isLastRequestWithKnownStatusDeletion("TEST_12345678901") verify(requestRepository, times(1)).findAllByPatientIdOrderByProcessedAtDesc(anyString()) } -- cgit v1.2.3