mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-19 17:26:51 +00:00
refactor: add additional constructors
This commit is contained in:
parent
3bd7239812
commit
5fcc24f915
@ -76,33 +76,33 @@ class RequestServiceIntegrationTest : AbstractTestcontainerTest() {
|
||||
this.requestRepository.saveAll(
|
||||
listOf(
|
||||
Request(
|
||||
uuid = UUID.randomUUID().toString(),
|
||||
patientId = "TEST_12345678901",
|
||||
pid = "P1",
|
||||
fingerprint = "0123456789abcdef1",
|
||||
type = RequestType.MTB_FILE,
|
||||
status = RequestStatus.SUCCESS,
|
||||
processedAt = Instant.parse("2023-07-07T02:00:00Z")
|
||||
UUID.randomUUID().toString(),
|
||||
"TEST_12345678901",
|
||||
"P1",
|
||||
"0123456789abcdef1",
|
||||
RequestType.MTB_FILE,
|
||||
RequestStatus.SUCCESS,
|
||||
Instant.parse("2023-07-07T02:00:00Z")
|
||||
),
|
||||
// Should be ignored - wrong patient ID -->
|
||||
Request(
|
||||
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")
|
||||
UUID.randomUUID().toString(),
|
||||
"TEST_12345678902",
|
||||
"P2",
|
||||
"0123456789abcdef2",
|
||||
RequestType.MTB_FILE,
|
||||
RequestStatus.WARNING,
|
||||
Instant.parse("2023-08-08T00:00:00Z")
|
||||
),
|
||||
// <--
|
||||
Request(
|
||||
uuid = UUID.randomUUID().toString(),
|
||||
patientId = "TEST_12345678901",
|
||||
pid = "P2",
|
||||
fingerprint = "0123456789abcdee1",
|
||||
type = RequestType.DELETE,
|
||||
status = RequestStatus.SUCCESS,
|
||||
processedAt = Instant.parse("2023-08-08T02:00:00Z")
|
||||
UUID.randomUUID().toString(),
|
||||
"TEST_12345678901",
|
||||
"P2",
|
||||
"0123456789abcdee1",
|
||||
RequestType.DELETE,
|
||||
RequestStatus.SUCCESS,
|
||||
Instant.parse("2023-08-08T02:00:00Z")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -43,7 +43,28 @@ data class Request(
|
||||
var status: RequestStatus,
|
||||
var processedAt: Instant = Instant.now(),
|
||||
@Embedded.Nullable var report: Report? = null
|
||||
)
|
||||
) {
|
||||
constructor(
|
||||
uuid: String,
|
||||
patientId: String,
|
||||
pid: String,
|
||||
fingerprint: String,
|
||||
type: RequestType,
|
||||
status: RequestStatus
|
||||
) :
|
||||
this(null, uuid, patientId, pid, fingerprint, type, status, Instant.now())
|
||||
|
||||
constructor(
|
||||
uuid: String,
|
||||
patientId: String,
|
||||
pid: String,
|
||||
fingerprint: String,
|
||||
type: RequestType,
|
||||
status: RequestStatus,
|
||||
processedAt: Instant
|
||||
) :
|
||||
this(null, uuid, patientId, pid, fingerprint, type, status, processedAt)
|
||||
}
|
||||
|
||||
@JvmRecord
|
||||
data class Report(
|
||||
|
@ -62,12 +62,12 @@ class RequestProcessor(
|
||||
|
||||
requestService.save(
|
||||
Request(
|
||||
uuid = requestId,
|
||||
patientId = request.mtbFile.patient.id,
|
||||
pid = pid,
|
||||
fingerprint = fingerprint(request.mtbFile),
|
||||
status = RequestStatus.UNKNOWN,
|
||||
type = RequestType.MTB_FILE
|
||||
requestId,
|
||||
request.mtbFile.patient.id,
|
||||
pid,
|
||||
fingerprint(request.mtbFile),
|
||||
RequestType.MTB_FILE,
|
||||
RequestStatus.UNKNOWN
|
||||
)
|
||||
)
|
||||
|
||||
@ -117,12 +117,12 @@ class RequestProcessor(
|
||||
|
||||
requestService.save(
|
||||
Request(
|
||||
uuid = requestId,
|
||||
patientId = patientPseudonym,
|
||||
pid = patientId,
|
||||
fingerprint = fingerprint(patientPseudonym),
|
||||
status = RequestStatus.UNKNOWN,
|
||||
type = RequestType.DELETE
|
||||
requestId,
|
||||
patientPseudonym,
|
||||
patientId,
|
||||
fingerprint(patientPseudonym),
|
||||
RequestType.DELETE,
|
||||
RequestStatus.UNKNOWN
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user