summaryrefslogtreecommitdiff
path: root/src/test/kotlin/dev/dnpm/etl/processor
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2023-08-11 09:13:45 +0200
committerGitHub2023-08-11 09:13:45 +0200
commitcb9c5904729c90b86357d0668604b74f4f4e61f7 (patch)
treebb104d05c9e75f449aee929d583aa7c52f6eb37e /src/test/kotlin/dev/dnpm/etl/processor
parent044d01534b1183449bfe7d2a783481b81feac455 (diff)
Issue #2: Do not serialize JSON string as custom string (#4)
In addition to that, if REST request did not contain a response body, use empty string as data quality report string.
Diffstat (limited to 'src/test/kotlin/dev/dnpm/etl/processor')
-rw-r--r--src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt60
1 files changed, 48 insertions, 12 deletions
diff --git a/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt
index 17d420a..78b5a45 100644
--- a/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt
+++ b/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt
@@ -61,7 +61,8 @@ class RestMtbFileSenderTest {
}
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
@@ -75,11 +76,16 @@ class RestMtbFileSenderTest {
}
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 {
- 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 = """
{
@@ -123,6 +129,8 @@ class RestMtbFileSenderTest {
)
.build()
+ private val errorResponseBody = "Sonstiger Fehler bei der Übertragung"
+
/**
* Synthetic http responses with related request status
* Also see: https://ibmi-intra.cs.uni-tuebingen.de/display/ZPM/bwHC+REST+API
@@ -130,13 +138,33 @@ class RestMtbFileSenderTest {
@JvmStatic
fun mtbFileRequestWithResponseSource(): Set<RequestWithResponse> {
return setOf(
- RequestWithResponse(HttpStatus.OK, "{}", RequestStatus.SUCCESS),
- RequestWithResponse(HttpStatus.CREATED, warningBody, RequestStatus.WARNING),
- RequestWithResponse(HttpStatus.BAD_REQUEST, "??", RequestStatus.ERROR),
- RequestWithResponse(HttpStatus.UNPROCESSABLE_ENTITY, errorBody, RequestStatus.ERROR),
+ RequestWithResponse(HttpStatus.OK, "{}", MtbFileSender.Response(RequestStatus.SUCCESS, "{}")),
+ RequestWithResponse(
+ HttpStatus.CREATED,
+ 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
- RequestWithResponse(HttpStatus.NOT_FOUND, "what????", RequestStatus.ERROR),
- RequestWithResponse(HttpStatus.INTERNAL_SERVER_ERROR, "what????", RequestStatus.ERROR)
+ RequestWithResponse(
+ 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
fun deleteRequestWithResponseSource(): Set<RequestWithResponse> {
return setOf(
- RequestWithResponse(HttpStatus.OK, "", RequestStatus.SUCCESS),
+ RequestWithResponse(HttpStatus.OK, "", MtbFileSender.Response(RequestStatus.SUCCESS)),
// Some more errors not mentioned in documentation
- RequestWithResponse(HttpStatus.NOT_FOUND, "what????", RequestStatus.ERROR),
- RequestWithResponse(HttpStatus.INTERNAL_SERVER_ERROR, "what????", RequestStatus.ERROR)
+ RequestWithResponse(
+ HttpStatus.NOT_FOUND,
+ "what????",
+ MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
+ ),
+ RequestWithResponse(
+ HttpStatus.INTERNAL_SERVER_ERROR,
+ "what????",
+ MtbFileSender.Response(RequestStatus.ERROR, errorResponseBody)
+ )
)
}
}