In my webflux application, i have this GET
endpoint
v3/callback?state=cGF5bWVudGlkPTRiMmZlMG
I am trying to write an integration test using WebTestClient
@Test
public void happyScenario() {
webTestClient.get().uri("/v3/callback?state=cGF5bWVudGlkPTRiMmZlMG")
.exchange()
.expectStatus()
.isOk();
}
This test case return 404 notFound
, if i removed the query parameter it will be called but the state
parameter it will be missing
I tried to use attribute
webTestClient.get().uri("/v3/callback")
.attribute("state","cGF5bWVudGlkPTRiMmZlMG")
.exchange()
.expectStatus()
.isOk();
but still the state
parameter is missing, How can i include a query parameter with request when using webTestClient
?
You can make use of UriBuilder
.
webTestClient.get()
.uri(uriBuilder ->
uriBuilder
.path("/v3/callback")
.queryParam("state", "cGF5bWVudGlkPTRiMmZlMG")
.build())
.exchange()
.expectStatus()
.isOk();
This should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With