mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-07-05 16:02:55 +00:00
Code cleanup
This commit is contained in:
@ -105,7 +105,7 @@ class RestMtbFileSenderTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val mtbFile = MtbFile.builder()
|
||||
val mtbFile: MtbFile = MtbFile.builder()
|
||||
.withPatient(
|
||||
Patient.builder()
|
||||
.withId("PID")
|
||||
@ -129,7 +129,7 @@ class RestMtbFileSenderTest {
|
||||
)
|
||||
.build()
|
||||
|
||||
private val errorResponseBody = "Sonstiger Fehler bei der Übertragung"
|
||||
private const val ERROR_RESPONSE_BODY = "Sonstiger Fehler bei der Übertragung"
|
||||
|
||||
/**
|
||||
* Synthetic http responses with related request status
|
||||
@ -147,23 +147,23 @@ class RestMtbFileSenderTest {
|
||||
RequestWithResponse(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"??",
|
||||
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||
MtbFileSender.Response(RequestStatus.ERROR, ERROR_RESPONSE_BODY)
|
||||
),
|
||||
RequestWithResponse(
|
||||
HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
errorBody,
|
||||
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||
MtbFileSender.Response(RequestStatus.ERROR, ERROR_RESPONSE_BODY)
|
||||
),
|
||||
// Some more errors not mentioned in documentation
|
||||
RequestWithResponse(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"what????",
|
||||
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||
MtbFileSender.Response(RequestStatus.ERROR, ERROR_RESPONSE_BODY)
|
||||
),
|
||||
RequestWithResponse(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
"what????",
|
||||
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||
MtbFileSender.Response(RequestStatus.ERROR, ERROR_RESPONSE_BODY)
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -180,12 +180,12 @@ class RestMtbFileSenderTest {
|
||||
RequestWithResponse(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"what????",
|
||||
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||
MtbFileSender.Response(RequestStatus.ERROR, ERROR_RESPONSE_BODY)
|
||||
),
|
||||
RequestWithResponse(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
"what????",
|
||||
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||
MtbFileSender.Response(RequestStatus.ERROR, ERROR_RESPONSE_BODY)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package dev.dnpm.etl.processor.services
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||
import dev.dnpm.etl.processor.monitoring.Request
|
||||
import dev.dnpm.etl.processor.monitoring.RequestRepository
|
||||
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
||||
@ -62,12 +60,10 @@ class ResponseProcessorTest {
|
||||
@Mock requestRepository: RequestRepository,
|
||||
@Mock statisticsUpdateProducer: Sinks.Many<Any>
|
||||
) {
|
||||
val objectMapper = ObjectMapper().registerModule(KotlinModule.Builder().build())
|
||||
|
||||
this.requestRepository = requestRepository
|
||||
this.statisticsUpdateProducer = statisticsUpdateProducer
|
||||
|
||||
this.responseProcessor = ResponseProcessor(requestRepository, statisticsUpdateProducer, objectMapper)
|
||||
this.responseProcessor = ResponseProcessor(requestRepository, statisticsUpdateProducer)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,7 +45,7 @@ class KafkaResponseProcessorTest {
|
||||
|
||||
private lateinit var kafkaResponseProcessor: KafkaResponseProcessor
|
||||
|
||||
private fun createkafkaRecord(
|
||||
private fun createKafkaRecord(
|
||||
requestId: String? = null,
|
||||
statusCode: Int = 200,
|
||||
statusBody: Map<String, Any>? = mapOf()
|
||||
@ -79,14 +79,14 @@ class KafkaResponseProcessorTest {
|
||||
|
||||
@Test
|
||||
fun shouldNotProcessRecordsWithoutValidKey() {
|
||||
this.kafkaResponseProcessor.onMessage(createkafkaRecord(null, 200))
|
||||
this.kafkaResponseProcessor.onMessage(createKafkaRecord(null, 200))
|
||||
|
||||
verify(eventPublisher, never()).publishEvent(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldNotProcessRecordsWithoutValidBody() {
|
||||
this.kafkaResponseProcessor.onMessage(createkafkaRecord(requestId = "TestID1234", statusBody = null))
|
||||
this.kafkaResponseProcessor.onMessage(createKafkaRecord(requestId = "TestID1234", statusBody = null))
|
||||
|
||||
verify(eventPublisher, never()).publishEvent(any())
|
||||
}
|
||||
@ -94,7 +94,7 @@ class KafkaResponseProcessorTest {
|
||||
@ParameterizedTest
|
||||
@MethodSource("statusCodeSource")
|
||||
fun shouldProcessValidRecordsWithStatusCode(statusCode: Int) {
|
||||
this.kafkaResponseProcessor.onMessage(createkafkaRecord("TestID1234", statusCode))
|
||||
this.kafkaResponseProcessor.onMessage(createKafkaRecord("TestID1234", statusCode))
|
||||
verify(eventPublisher, times(1)).publishEvent(any<ResponseEvent>())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user