44import static java .net .HttpURLConnection .HTTP_UNSUPPORTED_TYPE ;
55import static org .assertj .core .api .Assertions .assertThat ;
66import static org .assertj .core .api .Assertions .assertThatThrownBy ;
7+ import static org .mockito .ArgumentMatchers .any ;
8+ import static org .mockito .Mockito .doAnswer ;
79import static org .mockito .Mockito .mock ;
10+ import static org .mockito .Mockito .verify ;
11+ import static org .mockito .Mockito .when ;
812
913import com .retailsvc .http .BadRequestException ;
1014import com .retailsvc .http .ExceptionHandler ;
4145import java .util .concurrent .atomic .AtomicReference ;
4246import java .util .zip .GZIPOutputStream ;
4347import org .junit .jupiter .api .Test ;
44- import org .mockito .Mockito ;
4548
4649class RequestPreparationFilterTest {
4750
@@ -51,10 +54,10 @@ private HttpExchange exchange(String method, String path, byte[] body) {
5154
5255 private HttpExchange exchange (String method , String path , byte [] body , Headers headers ) {
5356 HttpExchange ex = mock (HttpExchange .class );
54- Mockito . when (ex .getRequestMethod ()).thenReturn (method );
55- Mockito . when (ex .getRequestURI ()).thenReturn (URI .create (path ));
56- Mockito . when (ex .getRequestHeaders ()).thenReturn (headers );
57- Mockito . when (ex .getRequestBody ()).thenReturn (new ByteArrayInputStream (body ));
57+ when (ex .getRequestMethod ()).thenReturn (method );
58+ when (ex .getRequestURI ()).thenReturn (URI .create (path ));
59+ when (ex .getRequestHeaders ()).thenReturn (headers );
60+ when (ex .getRequestBody ()).thenReturn (new ByteArrayInputStream (body ));
5861 return ex ;
5962 }
6063
@@ -140,21 +143,21 @@ void successPathBindsRequestContextDuringChain() throws Exception {
140143 AtomicReference <Map <String , String >> seenPathParams = new AtomicReference <>();
141144
142145 Filter .Chain chain = mock (Filter .Chain .class );
143- Mockito . doAnswer (
146+ doAnswer (
144147 inv -> {
145148 Request req = DispatchHandler .CURRENT .get ();
146149 seenOpId .set (req .operationId ());
147150 seenPathParams .set (req .pathParams ());
148151 return null ;
149152 })
150153 .when (chain )
151- .doFilter (Mockito . any ());
154+ .doFilter (any ());
152155
153156 f .doFilter (ex , chain );
154157
155158 assertThat (seenOpId .get ()).isEqualTo ("get-user" );
156159 assertThat (seenPathParams .get ()).containsEntry ("id" , "42" );
157- Mockito . verify (chain ).doFilter (ex );
160+ verify (chain ).doFilter (ex );
158161 }
159162
160163 @ Test
@@ -241,7 +244,7 @@ void integerQueryParamIsCoercedFromStringBeforeValidation() throws Exception {
241244 HttpExchange ex = exchange ("GET" , "/x?n=42" , new byte [0 ]);
242245 Filter .Chain chain = mock (Filter .Chain .class );
243246 f .doFilter (ex , chain );
244- Mockito . verify (chain ).doFilter (ex );
247+ verify (chain ).doFilter (ex );
245248 }
246249
247250 @ Test
@@ -288,7 +291,7 @@ void numberQueryParamIsCoercedFromStringBeforeValidation() throws Exception {
288291 HttpExchange ex = exchange ("GET" , "/x?n=1.5" , new byte [0 ]);
289292 Filter .Chain chain = mock (Filter .Chain .class );
290293 f .doFilter (ex , chain );
291- Mockito . verify (chain ).doFilter (ex );
294+ verify (chain ).doFilter (ex );
292295 }
293296
294297 @ Test
@@ -337,8 +340,8 @@ void booleanQueryParamCoercesTrueAndFalse() throws Exception {
337340 HttpExchange falseEx = exchange ("GET" , "/x?b=false" , new byte [0 ]);
338341 f .doFilter (trueEx , trueChain );
339342 f .doFilter (falseEx , falseChain );
340- Mockito . verify (trueChain ).doFilter (trueEx );
341- Mockito . verify (falseChain ).doFilter (falseEx );
343+ verify (trueChain ).doFilter (trueEx );
344+ verify (falseChain ).doFilter (falseEx );
342345 }
343346
344347 @ Test
@@ -383,15 +386,15 @@ void gzipRequestBodyIsInflatedBeforeValidation() throws Exception {
383386 AtomicReference <byte []> seenBody = new AtomicReference <>();
384387 AtomicReference <String > seenEncoding = new AtomicReference <>("still here" );
385388 Filter .Chain chain = mock (Filter .Chain .class );
386- Mockito . doAnswer (
389+ doAnswer (
387390 inv -> {
388391 Request req = DispatchHandler .CURRENT .get ();
389392 seenBody .set (req .bytes ());
390393 seenEncoding .set (req .header ("Content-Encoding" ).orElse (null ));
391394 return null ;
392395 })
393396 .when (chain )
394- .doFilter (Mockito . any ());
397+ .doFilter (any ());
395398
396399 f .doFilter (ex , chain );
397400
0 commit comments