mercredi 16 octobre 2019

Spring webflux WebTestClient with query parameter

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/payments/domestic/sign/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 ?

Aucun commentaire:

Enregistrer un commentaire