Skip to content

Allow Consumer-style access to FluxExchangeResult within chain of calls [SPR-15959] #20511

@spring-projects-issues

Description

@spring-projects-issues

Rob Winch opened SPR-15959 and commented

Currently ExchangeResult.assertWithDiagnostics accepts a Runnable which works fine for assertions within ExchangeResult because other methods have a reference to the ExchangeResult to create a Runnable which performs the assertion.

However, a Runnable does not work nicely for an external user who wants to perform an assertion. Currently they must do something like:

FluxExchangeResult<String> result = client.get()
	.exchange()
	.expectStatus()
	.isOk()
	.returnResult(String.class);
result.assertWithDiagnostics(() -> assertThat(result.getResponseCookies().isEmpty()));

It would be nice if assertWithDiagnostics accepted a Consuer<ExchangeResult> so that the code can be refactored to be something like:

client.get()
	.exchange()
	.expectStatus()
	.isOk()
	.returnResult(String.class)
	.assertWithDiagnostics( result -> assertThat(result.getResponseCookies().isEmpty()));

Affects: 5.0 RC4

Issue Links:

Referenced from: commits d742fc1

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions