Interface RestTestClient.Builder<B extends RestTestClient.Builder<B>>
- Type Parameters:
- B- the type of builder
- All Known Subinterfaces:
- RestTestClient.MockMvcSetupBuilder<S,- M>, RestTestClient.RouterFunctionSetupBuilder, RestTestClient.StandaloneSetupBuilder, RestTestClient.WebAppContextSetupBuilder 
- Enclosing interface:
- RestTestClient
public static interface RestTestClient.Builder<B extends RestTestClient.Builder<B>>
Steps to customize the underlying 
RestClient via RestClient.Builder.- Since:
- 7.0
- Author:
- Rob Worsnop, Rossen Stoyanchev
- 
Method SummaryModifier and TypeMethodDescription<T extends B>
 TapiVersionInserter(@Nullable ApiVersionInserter apiVersionInserter) Configure anApiVersionInserterto abstract how an API version specified viaRestTestClient.RequestHeadersSpec.apiVersion(Object)is inserted into the request.<T extends B>
 TConfigure a base URI as described inRestClient.create(String).build()Build theRestTestClientinstance.<T extends B>
 TConfigure the message converters to use for the request and response body.<T extends B>
 TdefaultApiVersion(Object version) Global option to specify an API version to add to every request, if not already set.<T extends B>
 TdefaultCookie(String cookieName, String... cookieValues) Add the given cookie to all requests that have not already added it.<T extends B>
 TdefaultCookies(Consumer<MultiValueMap<String, String>> cookiesConsumer) Manipulate the default cookies with the given consumer.<T extends B>
 TdefaultHeader(String headerName, String... headerValues) Add the given header to all requests that have not added it.<T extends B>
 TdefaultHeaders(Consumer<HttpHeaders> headersConsumer) Manipulate the default headers with the given consumer.<T extends B>
 TentityExchangeResultConsumer(Consumer<EntityExchangeResult<?>> consumer) Configure anEntityExchangeResultcallback that is invoked every time after a response is fully decoded to a single entity, to a List of entities, or to a byte[].<T extends B>
 TrequestInterceptor(ClientHttpRequestInterceptor interceptor) Add the given request interceptor to the end of the interceptor chain.<T extends B>
 TrequestInterceptors(Consumer<List<ClientHttpRequestInterceptor>> interceptorsConsumer) Manipulate the interceptors with the given consumer.<T extends B>
 TuriBuilderFactory(UriBuilderFactory uriBuilderFactory) Provide a pre-configuredUriBuilderFactoryinstance as an alternative to and effectively overridingbaseUrl(String).
- 
Method Details- 
baseUrlConfigure a base URI as described inRestClient.create(String).- Returns:
- this builder
 
- 
uriBuilderFactoryProvide a pre-configuredUriBuilderFactoryinstance as an alternative to and effectively overridingbaseUrl(String).- Returns:
- this builder
 
- 
defaultHeader
- 
defaultHeadersManipulate the default headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the otherHttpHeadersmethods.- Parameters:
- headersConsumer- a function that consumes the- HttpHeaders
- Returns:
- this builder
 
- 
defaultCookie
- 
defaultCookiesManipulate the default cookies with the given consumer. The map provided to the consumer is "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the otherMultiValueMapmethods.- Parameters:
- cookiesConsumer- a function that consumes the cookies map
- Returns:
- this builder
 
- 
defaultApiVersion
- 
apiVersionInserterConfigure anApiVersionInserterto abstract how an API version specified viaRestTestClient.RequestHeadersSpec.apiVersion(Object)is inserted into the request.ApiVersionInserterexposes shortcut methods for several built-in inserter implementation types. See the class-level Javadoc ofApiVersionInserterfor a list of choices.- Parameters:
- apiVersionInserter- the inserter to use
 
- 
requestInterceptorAdd the given request interceptor to the end of the interceptor chain.- Parameters:
- interceptor- the interceptor to be added to the chain
 
- 
requestInterceptors<T extends B> T requestInterceptors(Consumer<List<ClientHttpRequestInterceptor>> interceptorsConsumer) Manipulate the interceptors with the given consumer. The list provided to the consumer is "live", so that the consumer can be used to remove interceptors, change ordering, etc.- Parameters:
- interceptorsConsumer- a function that consumes the interceptors list
- Returns:
- this builder
 
- 
configureMessageConverters<T extends B> T configureMessageConverters(Consumer<HttpMessageConverters.ClientBuilder> configurer) Configure the message converters to use for the request and response body.- Parameters:
- configurer- the configurer to apply on an empty- HttpMessageConverters.ClientBuilder.
- Returns:
- this builder
 
- 
entityExchangeResultConsumerConfigure anEntityExchangeResultcallback that is invoked every time after a response is fully decoded to a single entity, to a List of entities, or to a byte[]. In effect, this is equivalent to each of the below but registered only once, globally.client.get().uri("/accounts/1") .exchange() .expectBody(Person.class).consumeWith(exchangeResult -> ... )); client.get().uri("/accounts") .exchange() .expectBodyList(Person.class).consumeWith(exchangeResult -> ... )); client.get().uri("/accounts/1") .exchange() .expectBody().consumeWith(exchangeResult -> ... ));Note that the configured consumer does not apply to responses decoded to Flux<T>which can be consumed outside the workflow of the test client, for example viareactor.test.StepVerifier.- Parameters:
- consumer- the consumer to apply to entity responses
- Returns:
- the builder
 
- 
buildRestTestClient build()Build theRestTestClientinstance.
 
-