12
12
*/
13
13
package org .asynchttpclient .extras .retrofit ;
14
14
15
+ import static org .asynchttpclient .extras .retrofit .AsyncHttpClientCall .*;
16
+ import static org .mockito .Matchers .any ;
17
+ import static org .mockito .Mockito .*;
18
+ import static org .testng .Assert .assertTrue ;
15
19
import io .netty .handler .codec .http .EmptyHttpHeaders ;
16
- import lombok .extern .slf4j .Slf4j ;
17
- import lombok .val ;
18
- import okhttp3 .Request ;
19
- import org .asynchttpclient .AsyncCompletionHandler ;
20
- import org .asynchttpclient .AsyncHttpClient ;
21
- import org .asynchttpclient .BoundRequestBuilder ;
22
- import org .asynchttpclient .Response ;
23
- import org .testng .Assert ;
24
- import org .testng .annotations .DataProvider ;
25
- import org .testng .annotations .Test ;
26
20
27
21
import java .io .IOException ;
28
22
import java .util .Arrays ;
32
26
import java .util .concurrent .atomic .AtomicInteger ;
33
27
import java .util .function .Consumer ;
34
28
35
- import static org .asynchttpclient .extras .retrofit .AsyncHttpClientCall .runConsumer ;
36
- import static org .asynchttpclient .extras .retrofit .AsyncHttpClientCall .runConsumers ;
37
- import static org .mockito .Matchers .any ;
38
- import static org .mockito .Mockito .mock ;
39
- import static org .mockito .Mockito .when ;
40
- import static org .testng .Assert .assertTrue ;
29
+ import lombok .val ;
30
+ import okhttp3 .Request ;
31
+
32
+ import org .asynchttpclient .AsyncCompletionHandler ;
33
+ import org .asynchttpclient .AsyncHttpClient ;
34
+ import org .asynchttpclient .BoundRequestBuilder ;
35
+ import org .asynchttpclient .Response ;
36
+ import org .testng .Assert ;
37
+ import org .testng .annotations .DataProvider ;
38
+ import org .testng .annotations .Test ;
41
39
42
- @ Slf4j
43
40
public class AsyncHttpClientCallTest {
44
41
static final Request REQUEST = new Request .Builder ().url ("http://www.google.com/" ).build ();
45
42
@@ -60,7 +57,7 @@ Object[][] dataProviderFirst() {
60
57
}
61
58
62
59
@ Test (dataProvider = "second" )
63
- void shouldInvokeConsumersOnEachExecution (Consumer <AsyncCompletionHandler > handlerConsumer ,
60
+ void shouldInvokeConsumersOnEachExecution (Consumer <AsyncCompletionHandler <?> > handlerConsumer ,
64
61
int expectedStarted ,
65
62
int expectedOk ,
66
63
int expectedFailed ) {
@@ -82,6 +79,7 @@ void shouldInvokeConsumersOnEachExecution(Consumer<AsyncCompletionHandler> handl
82
79
when (httpClient .prepareRequest ((org .asynchttpclient .RequestBuilder ) any ())).thenReturn (brb );
83
80
84
81
when (httpClient .executeRequest ((org .asynchttpclient .Request ) any (), any ())).then (invocationOnMock -> {
82
+ @ SuppressWarnings ("rawtypes" )
85
83
val handler = invocationOnMock .getArgumentAt (1 , AsyncCompletionHandler .class );
86
84
handlerConsumer .accept (handler );
87
85
return null ;
@@ -140,15 +138,13 @@ Object[][] dataProviderSecond() {
140
138
when (response .getStatusText ()).thenReturn ("OK" );
141
139
when (response .getHeaders ()).thenReturn (EmptyHttpHeaders .INSTANCE );
142
140
143
- AsyncCompletionHandler x = null ;
144
-
145
- Consumer <AsyncCompletionHandler > okConsumer = handler -> {
141
+ Consumer <AsyncCompletionHandler <?>> okConsumer = handler -> {
146
142
try {
147
143
handler .onCompleted (response );
148
144
} catch (Exception e ) {
149
145
}
150
146
};
151
- Consumer <AsyncCompletionHandler > failedConsumer = handler -> handler .onThrowable (new TimeoutException ("foo" ));
147
+ Consumer <AsyncCompletionHandler <?> > failedConsumer = handler -> handler .onThrowable (new TimeoutException ("foo" ));
152
148
153
149
return new Object [][]{
154
150
{okConsumer , 1 , 1 , 0 },
0 commit comments