mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-07-02 22:42:55 +00:00
refactor: add additional constructors
This commit is contained in:
@ -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())
|
||||
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user