Skip to content

Add a exchange() variant to RestTestClient that expects 2xx response #35582

@donalmurtagh

Description

@donalmurtagh

When using RestClient it's possible to submit a request that's expected to succeed via

restClient.post()
    .uri("/foo/bar")
    .body(requestData)
    .retrieve();

With a RestTestClient the equivalent is

restTestClient.post()
    .uri("/foo/bar")
    .body(requestData)
    .exchange()
    .expectStatus().is2xxSuccessful();

Could we add a correspondingretrieve() method to the RestTestClient API? Not only would it make the code a bit more concise for the very common case of submitting a request that's expected to succeed, but it would simplify migrating from RestClient to RestTestClient

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions