mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-20 01:36:50 +00:00
In addition to that, if REST request did not contain a response body, use empty string as data quality report string.
This commit is contained in:
parent
044d01534b
commit
cb9c590472
@ -50,7 +50,7 @@ class RestMtbFileSender(
|
|||||||
return MtbFileSender.Response(response.statusCode.asRequestStatus(), "Status-Code: ${response.statusCode.value()}")
|
return MtbFileSender.Response(response.statusCode.asRequestStatus(), "Status-Code: ${response.statusCode.value()}")
|
||||||
}
|
}
|
||||||
logger.debug("Sent file via RestMtbFileSender")
|
logger.debug("Sent file via RestMtbFileSender")
|
||||||
return MtbFileSender.Response(response.statusCode.asRequestStatus())
|
return MtbFileSender.Response(response.statusCode.asRequestStatus(), response.body.orEmpty())
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
logger.error("Not a valid URI to export to: '{}'", restTargetProperties.uri!!)
|
logger.error("Not a valid URI to export to: '{}'", restTargetProperties.uri!!)
|
||||||
} catch (e: RestClientException) {
|
} catch (e: RestClientException) {
|
||||||
|
@ -55,14 +55,14 @@ class ResponseProcessor(
|
|||||||
RequestStatus.WARNING -> {
|
RequestStatus.WARNING -> {
|
||||||
it.report = Report(
|
it.report = Report(
|
||||||
"Warnungen über mangelhafte Daten",
|
"Warnungen über mangelhafte Daten",
|
||||||
objectMapper.writeValueAsString(event.body)
|
event.body.orElse("")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestStatus.ERROR -> {
|
RequestStatus.ERROR -> {
|
||||||
it.report = Report(
|
it.report = Report(
|
||||||
"Fehler bei der Datenübertragung oder Inhalt nicht verarbeitbar",
|
"Fehler bei der Datenübertragung oder Inhalt nicht verarbeitbar",
|
||||||
objectMapper.writeValueAsString(event.body)
|
event.body.orElse("")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,8 @@ class RestMtbFileSenderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val response = restMtbFileSender.send(MtbFileSender.DeleteRequest("TestID", "PID"))
|
val response = restMtbFileSender.send(MtbFileSender.DeleteRequest("TestID", "PID"))
|
||||||
assertThat(response.status).isEqualTo(requestWithResponse.requestStatus)
|
assertThat(response.status).isEqualTo(requestWithResponse.response.status)
|
||||||
|
assertThat(response.body).isEqualTo(requestWithResponse.response.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ -75,11 +76,16 @@ class RestMtbFileSenderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val response = restMtbFileSender.send(MtbFileSender.MtbFileRequest("TestID", mtbFile))
|
val response = restMtbFileSender.send(MtbFileSender.MtbFileRequest("TestID", mtbFile))
|
||||||
assertThat(response.status).isEqualTo(requestWithResponse.requestStatus)
|
assertThat(response.status).isEqualTo(requestWithResponse.response.status)
|
||||||
|
assertThat(response.body).isEqualTo(requestWithResponse.response.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
data class RequestWithResponse(val httpStatus: HttpStatus, val body: String, val requestStatus: RequestStatus)
|
data class RequestWithResponse(
|
||||||
|
val httpStatus: HttpStatus,
|
||||||
|
val body: String,
|
||||||
|
val response: MtbFileSender.Response
|
||||||
|
)
|
||||||
|
|
||||||
private val warningBody = """
|
private val warningBody = """
|
||||||
{
|
{
|
||||||
@ -123,6 +129,8 @@ class RestMtbFileSenderTest {
|
|||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
private val errorResponseBody = "Sonstiger Fehler bei der Übertragung"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synthetic http responses with related request status
|
* Synthetic http responses with related request status
|
||||||
* Also see: https://ibmi-intra.cs.uni-tuebingen.de/display/ZPM/bwHC+REST+API
|
* Also see: https://ibmi-intra.cs.uni-tuebingen.de/display/ZPM/bwHC+REST+API
|
||||||
@ -130,13 +138,33 @@ class RestMtbFileSenderTest {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun mtbFileRequestWithResponseSource(): Set<RequestWithResponse> {
|
fun mtbFileRequestWithResponseSource(): Set<RequestWithResponse> {
|
||||||
return setOf(
|
return setOf(
|
||||||
RequestWithResponse(HttpStatus.OK, "{}", RequestStatus.SUCCESS),
|
RequestWithResponse(HttpStatus.OK, "{}", MtbFileSender.Response(RequestStatus.SUCCESS, "{}")),
|
||||||
RequestWithResponse(HttpStatus.CREATED, warningBody, RequestStatus.WARNING),
|
RequestWithResponse(
|
||||||
RequestWithResponse(HttpStatus.BAD_REQUEST, "??", RequestStatus.ERROR),
|
HttpStatus.CREATED,
|
||||||
RequestWithResponse(HttpStatus.UNPROCESSABLE_ENTITY, errorBody, RequestStatus.ERROR),
|
warningBody,
|
||||||
|
MtbFileSender.Response(RequestStatus.WARNING, warningBody)
|
||||||
|
),
|
||||||
|
RequestWithResponse(
|
||||||
|
HttpStatus.BAD_REQUEST,
|
||||||
|
"??",
|
||||||
|
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||||
|
),
|
||||||
|
RequestWithResponse(
|
||||||
|
HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
errorBody,
|
||||||
|
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||||
|
),
|
||||||
// Some more errors not mentioned in documentation
|
// Some more errors not mentioned in documentation
|
||||||
RequestWithResponse(HttpStatus.NOT_FOUND, "what????", RequestStatus.ERROR),
|
RequestWithResponse(
|
||||||
RequestWithResponse(HttpStatus.INTERNAL_SERVER_ERROR, "what????", RequestStatus.ERROR)
|
HttpStatus.NOT_FOUND,
|
||||||
|
"what????",
|
||||||
|
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||||
|
),
|
||||||
|
RequestWithResponse(
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
"what????",
|
||||||
|
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,10 +175,18 @@ class RestMtbFileSenderTest {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun deleteRequestWithResponseSource(): Set<RequestWithResponse> {
|
fun deleteRequestWithResponseSource(): Set<RequestWithResponse> {
|
||||||
return setOf(
|
return setOf(
|
||||||
RequestWithResponse(HttpStatus.OK, "", RequestStatus.SUCCESS),
|
RequestWithResponse(HttpStatus.OK, "", MtbFileSender.Response(RequestStatus.SUCCESS)),
|
||||||
// Some more errors not mentioned in documentation
|
// Some more errors not mentioned in documentation
|
||||||
RequestWithResponse(HttpStatus.NOT_FOUND, "what????", RequestStatus.ERROR),
|
RequestWithResponse(
|
||||||
RequestWithResponse(HttpStatus.INTERNAL_SERVER_ERROR, "what????", RequestStatus.ERROR)
|
HttpStatus.NOT_FOUND,
|
||||||
|
"what????",
|
||||||
|
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||||
|
),
|
||||||
|
RequestWithResponse(
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
"what????",
|
||||||
|
MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user