@@ -185,37 +185,34 @@ private class DefaultRequestBodyUriSpec implements RequestBodyUriSpec {
185
185
186
186
private final Map <String , Object > attributes = new LinkedHashMap <>(4 );
187
187
188
- @ Nullable
189
- private Consumer <ClientHttpRequest > httpRequestConsumer ;
190
-
191
188
@ Nullable
192
189
private String uriTemplate ;
193
190
194
191
private final String requestId ;
195
192
196
193
DefaultRequestBodyUriSpec (HttpMethod httpMethod ) {
197
194
this .httpMethod = httpMethod ;
198
- this .requestId = String .valueOf (requestIndex .incrementAndGet ());
195
+ this .requestId = String .valueOf (DefaultWebTestClient . this . requestIndex .incrementAndGet ());
199
196
this .headers = new HttpHeaders ();
200
197
this .headers .add (WebTestClient .WEBTESTCLIENT_REQUEST_ID , this .requestId );
201
198
}
202
199
203
200
@ Override
204
201
public RequestBodySpec uri (String uriTemplate , Object ... uriVariables ) {
205
202
this .uriTemplate = uriTemplate ;
206
- return uri (uriBuilderFactory .expand (uriTemplate , uriVariables ));
203
+ return uri (DefaultWebTestClient . this . uriBuilderFactory .expand (uriTemplate , uriVariables ));
207
204
}
208
205
209
206
@ Override
210
207
public RequestBodySpec uri (String uriTemplate , Map <String , ?> uriVariables ) {
211
208
this .uriTemplate = uriTemplate ;
212
- return uri (uriBuilderFactory .expand (uriTemplate , uriVariables ));
209
+ return uri (DefaultWebTestClient . this . uriBuilderFactory .expand (uriTemplate , uriVariables ));
213
210
}
214
211
215
212
@ Override
216
213
public RequestBodySpec uri (Function <UriBuilder , URI > uriFunction ) {
217
214
this .uriTemplate = null ;
218
- return uri (uriFunction .apply (uriBuilderFactory .builder ()));
215
+ return uri (uriFunction .apply (DefaultWebTestClient . this . uriBuilderFactory .builder ()));
219
216
}
220
217
221
218
@ Override
@@ -358,45 +355,39 @@ public ResponseSpec exchange() {
358
355
initRequestBuilder ().body (this .inserter ).build () :
359
356
initRequestBuilder ().build ());
360
357
361
- ClientResponse response = exchangeFunction .exchange (request ).block (getResponseTimeout ());
358
+ ClientResponse response = DefaultWebTestClient . this . exchangeFunction .exchange (request ).block (getResponseTimeout ());
362
359
Assert .state (response != null , "No ClientResponse" );
363
360
364
- ExchangeResult result = wiretapConnector .getExchangeResult (
361
+ ExchangeResult result = DefaultWebTestClient . this . wiretapConnector .getExchangeResult (
365
362
this .requestId , this .uriTemplate , getResponseTimeout ());
366
363
367
364
return new DefaultResponseSpec (result , response ,
368
365
DefaultWebTestClient .this .entityResultConsumer , getResponseTimeout ());
369
366
}
370
367
371
368
private ClientRequest .Builder initRequestBuilder () {
372
- ClientRequest . Builder builder = ClientRequest .create (this .httpMethod , initUri ())
369
+ return ClientRequest .create (this .httpMethod , initUri ())
373
370
.headers (headersToUse -> {
374
- if (!CollectionUtils .isEmpty (defaultHeaders )) {
375
- headersToUse .putAll (defaultHeaders );
371
+ if (!CollectionUtils .isEmpty (DefaultWebTestClient . this . defaultHeaders )) {
372
+ headersToUse .putAll (DefaultWebTestClient . this . defaultHeaders );
376
373
}
377
374
if (!CollectionUtils .isEmpty (this .headers )) {
378
375
headersToUse .putAll (this .headers );
379
376
}
380
377
})
381
378
.cookies (cookiesToUse -> {
382
- if (!CollectionUtils .isEmpty (defaultCookies )) {
383
- cookiesToUse .putAll (defaultCookies );
379
+ if (!CollectionUtils .isEmpty (DefaultWebTestClient . this . defaultCookies )) {
380
+ cookiesToUse .putAll (DefaultWebTestClient . this . defaultCookies );
384
381
}
385
382
if (!CollectionUtils .isEmpty (this .cookies )) {
386
383
cookiesToUse .putAll (this .cookies );
387
384
}
388
385
})
389
386
.attributes (attributes -> attributes .putAll (this .attributes ));
390
-
391
- if (this .httpRequestConsumer != null ) {
392
- builder .httpRequest (this .httpRequestConsumer );
393
- }
394
-
395
- return builder ;
396
387
}
397
388
398
389
private URI initUri () {
399
- return (this .uri != null ? this .uri : uriBuilderFactory .expand ("" ));
390
+ return (this .uri != null ? this .uri : DefaultWebTestClient . this . uriBuilderFactory .expand ("" ));
400
391
}
401
392
402
393
}
@@ -520,9 +511,7 @@ public ResponseSpec expectAll(ResponseSpecConsumer... consumers) {
520
511
// that is not a RuntimeException, but since ExceptionCollector may
521
512
// throw a checked Exception, we handle this to appease the compiler
522
513
// and in case someone uses a "sneaky throws" technique.
523
- AssertionError assertionError = new AssertionError (ex .getMessage ());
524
- assertionError .initCause (ex );
525
- throw assertionError ;
514
+ throw new AssertionError (ex .getMessage (), ex );
526
515
}
527
516
return this ;
528
517
}
0 commit comments