1616
1717package com .spotify .dns ;
1818
19- import static java .util .List .of ;
2019import static org .hamcrest .CoreMatchers .is ;
2120import static org .hamcrest .Matchers .containsInAnyOrder ;
2221import static org .junit .Assert .assertThat ;
2928import static org .mockito .Mockito .verifyNoMoreInteractions ;
3029import static org .mockito .Mockito .when ;
3130
31+ import java .util .Arrays ;
3232import java .util .List ;
3333import java .util .concurrent .CompletableFuture ;
34+ import java .util .concurrent .ExecutionException ;
3435import java .util .function .Function ;
3536import org .junit .Before ;
3637import org .junit .Test ;
@@ -62,9 +63,10 @@ public void shouldCallListenerOnChange() {
6263
6364 LookupResult result1 = result ("host" , 1234 );
6465 LookupResult result2 = result ("host" , 4321 );
65- when (resolver .resolve (FQDN )).thenReturn (of (result1 ), of (result1 , result2 ));
66+ when (resolver .resolve (FQDN )).thenReturn (Arrays . asList (result1 ), Arrays . asList (result1 , result2 ));
6667 when (resolver .resolveAsync (FQDN ))
67- .thenReturn (CompletableFuture .completedFuture (of (result1 )), CompletableFuture .completedFuture (of (result1 , result2 )));
68+ .thenReturn (CompletableFuture .completedFuture (Arrays .asList (result1 )),
69+ CompletableFuture .completedFuture (Arrays .asList (result1 , result2 )));
6870
6971 sut .run ();
7072 sut .run ();
@@ -96,9 +98,9 @@ public void shouldCallListenerOnSet() {
9698
9799 LookupResult result = result ("host" , 1234 );
98100 when (resolver .resolve (FQDN ))
99- .thenReturn (of (result ));
101+ .thenReturn (Arrays . asList (result ));
100102 when (resolver .resolveAsync (FQDN ))
101- .thenReturn (CompletableFuture .completedFuture (of (result )));
103+ .thenReturn (CompletableFuture .completedFuture (Arrays . asList (result )));
102104
103105 sut .run ();
104106 sut .setListener (listener , true );
@@ -122,9 +124,10 @@ public void shouldReturnImmutableSets() {
122124 LookupResult result1 = result ("host" , 1234 );
123125 LookupResult result2 = result ("host" , 4321 );
124126 when (resolver .resolve (FQDN ))
125- .thenReturn (of (result1 ), of (result1 , result2 ));
127+ .thenReturn (Arrays . asList (result1 ), Arrays . asList (result1 , result2 ));
126128 when (resolver .resolveAsync (FQDN ))
127- .thenReturn (CompletableFuture .completedFuture (of (result1 )), CompletableFuture .completedFuture (of (result1 , result2 )));
129+ .thenReturn (CompletableFuture .completedFuture (Arrays .asList (result1 )),
130+ CompletableFuture .completedFuture (Arrays .asList (result1 , result2 )));
128131
129132 sut .run ();
130133 sut .setListener (listener , true );
@@ -158,9 +161,10 @@ public void shouldOnlyChangeIfTransformedValuesChange() {
158161 LookupResult result1 = result ("host" , 1234 );
159162 LookupResult result2 = result ("host" , 4321 );
160163 when (resolver .resolve (FQDN ))
161- .thenReturn (of (result1 ), of (result1 , result2 ));
164+ .thenReturn (Arrays . asList (result1 ), Arrays . asList (result1 , result2 ));
162165 when (resolver .resolveAsync (FQDN ))
163- .thenReturn (CompletableFuture .completedFuture (of (result1 )), CompletableFuture .completedFuture (of (result1 , result2 )));
166+ .thenReturn (CompletableFuture .completedFuture (Arrays .asList (result1 )),
167+ CompletableFuture .completedFuture (Arrays .asList (result1 , result2 )));
164168
165169 sut .run ();
166170 sut .run ();
@@ -197,12 +201,12 @@ public void shouldDoSomethingWithNulls() {
197201 ChangeNotifier .Listener <String > listener = mock (ChangeNotifier .Listener .class );
198202
199203 when (resolver .resolve (FQDN ))
200- .thenReturn (of (
204+ .thenReturn (Arrays . asList (
201205 result ("host1" , 1234 ),
202206 result ("host2" , 1234 ),
203207 result ("host3" , 1234 )));
204208 when (resolver .resolveAsync (FQDN ))
205- .thenReturn (CompletableFuture .completedFuture (of (
209+ .thenReturn (CompletableFuture .completedFuture (Arrays . asList (
206210 result ("host1" , 1234 ),
207211 result ("host2" , 1234 ),
208212 result ("host3" , 1234 ))));
@@ -228,7 +232,7 @@ public void shouldCallErrorHandlerOnResolveErrors() {
228232 when (resolver .resolve (FQDN ))
229233 .thenThrow (exception );
230234 when (resolver .resolveAsync (FQDN ))
231- .thenReturn (CompletableFuture .failedFuture (exception ));
235+ .thenReturn (DnsTestUtil .failedFuture (exception ));
232236
233237 sut .setListener (listener , false );
234238 sut .run ();
0 commit comments