From d9b0256180ad77502baa2e4d6009381543a092a7 Mon Sep 17 00:00:00 2001 From: xcodeassociated Date: Tue, 17 Sep 2024 22:09:21 +0200 Subject: [PATCH] change external controller --- .../sample/http/external/api/ExternalController.kt | 8 +++++--- .../kotlin/com/softeno/template/app/IntegrationTest.kt | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/softeno/template/sample/http/external/api/ExternalController.kt b/src/main/kotlin/com/softeno/template/sample/http/external/api/ExternalController.kt index 667f8d2..a20fdbd 100644 --- a/src/main/kotlin/com/softeno/template/sample/http/external/api/ExternalController.kt +++ b/src/main/kotlin/com/softeno/template/sample/http/external/api/ExternalController.kt @@ -18,9 +18,11 @@ class ExternalController( private val log = LogFactory.getLog(javaClass) @GetMapping("/{id}") - fun getExternalResource(@PathVariable id: String): ResponseEntity { + fun getExternalResource(@PathVariable id: String): ResponseEntity { val data = externalServiceClient.fetchExternalResource(id) log.info("External: Received $id, sending: ${data.toString()}") - return ResponseEntity.ok(data) + return ResponseEntity.ok(SampleResponseDto(data = data ?: "null")) } -} \ No newline at end of file +} + +data class SampleResponseDto(val data: String) \ No newline at end of file diff --git a/src/test/kotlin/com/softeno/template/app/IntegrationTest.kt b/src/test/kotlin/com/softeno/template/app/IntegrationTest.kt index 3eed413..fdeb767 100644 --- a/src/test/kotlin/com/softeno/template/app/IntegrationTest.kt +++ b/src/test/kotlin/com/softeno/template/app/IntegrationTest.kt @@ -186,7 +186,11 @@ class ExternalControllerTest : BaseIntegrationTest(), ExternalApiAbility { .exchange() .expectStatus().isOk() .expectBody() - .jsonPath("data").isEqualTo("1") + .jsonPath("data").isEqualTo(""" + { + "data": "1" + } + """.trimIndent()) } }