Created
September 3, 2020 00:16
-
-
Save lkam88/3cb114c804d97939f0a22be59e9cee1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `send http request success`() = runBlocking { | |
mockHttpCall( | |
statusCode = 200, | |
jsonResponse = json { | |
obj( | |
"ip" to "1.1.1.1" | |
) | |
} | |
) | |
val responseFuture = vertx.eventBus().request<JsonObject>("${HttpWorkerVerticle.SERVICE_ADDRESS}.request.send", sampleHttpRequest.toJson()) | |
responseFuture.onComplete { handler -> | |
assertTrue(handler.succeeded()) | |
val responseBody = handler.result().body() | |
assertEquals("1.1.1.1", responseBody.getString("ip")) | |
} | |
responseFuture.await() | |
return@runBlocking | |
} | |
@Test | |
fun `send http request 500`() = runBlocking { | |
mockHttpCall( | |
statusCode = 500, | |
jsonResponse = json { | |
obj( | |
"ip" to "1.1.1.1" | |
) | |
} | |
) | |
val responseFuture = vertx.eventBus().request<JsonObject>("${HttpWorkerVerticle.SERVICE_ADDRESS}.request.send", sampleHttpRequest.toJson()) | |
responseFuture.onComplete { handler -> | |
assertTrue(handler.failed()) | |
} | |
responseFuture.await() | |
return@runBlocking | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment