类 FluxExchangeResult<T>
- java.lang.Object
- org.springframework.test.web.reactive.server.ExchangeResult
- org.springframework.test.web.reactive.server.FluxExchangeResult<T>
- 类型参数:
T
- the type of elements in the response body
public class FluxExchangeResult<T> extends ExchangeResult
ExchangeResult
variant with the response body decoded asFlux<T>
but not yet consumed.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
- 另请参阅:
EntityExchangeResult
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
consumeWith(Consumer<FluxExchangeResult<T>> consumer)
Invoke the given consumer withinExchangeResult.assertWithDiagnostics(Runnable)
passing"this"
instance to it.reactor.core.publisher.Flux<T>
getResponseBody()
Return the response body as aFlux<T>
of decoded elements.从类继承的方法 org.springframework.test.web.reactive.server.ExchangeResult
assertWithDiagnostics, getMethod, getRawStatusCode, getRequestBodyContent, getRequestHeaders, getResponseBodyContent, getResponseCookies, getResponseHeaders, getStatus, getUriTemplate, getUrl, toString
方法详细资料
getResponseBody
public reactor.core.publisher.Flux<T> getResponseBody()
Return the response body as aFlux<T>
of decoded elements.The response body stream can then be consumed further with the "reactor-test"
StepVerifier
and cancelled when enough elements have been consumed from the (possibly infinite) stream:FluxExchangeResult<Person> result = this.client.get() .uri("/persons") .accept(TEXT_EVENT_STREAM) .exchange() .expectStatus().isOk() .expectHeader().contentType(TEXT_EVENT_STREAM) .expectBody(Person.class) .returnResult(); StepVerifier.create(result.getResponseBody()) .expectNext(new Person("Jane"), new Person("Jason")) .expectNextCount(4) .expectNext(new Person("Jay")) .thenCancel() .verify();
consumeWith
public void consumeWith(Consumer<FluxExchangeResult<T>> consumer)
Invoke the given consumer withinExchangeResult.assertWithDiagnostics(Runnable)
passing"this"
instance to it. This method allows the following, without leaving theWebTestClient
chain of calls:client.get() .uri("/persons") .accept(TEXT_EVENT_STREAM) .exchange() .expectStatus().isOk() .returnResult() .consumeWith(result -> assertThat(...);
- 参数:
consumer
- the consumer for"this"
instance