22
33import static org .junit .jupiter .api .Assertions .assertNotNull ;
44import static org .junit .jupiter .api .Assertions .assertTrue ;
5+ import static org .mockito .ArgumentMatchers .any ;
56import static org .mockito .Mockito .mock ;
7+ import static org .mockito .Mockito .when ;
68
79import java .io .IOException ;
10+ import java .net .URL ;
11+ import java .util .concurrent .CompletableFuture ;
812
913import com .microsoft .graph .authentication .IAuthenticationProvider ;
1014import org .junit .jupiter .api .Test ;
@@ -22,11 +26,12 @@ public void telemetryInitTest() {
2226 }
2327
2428 @ Test
25- @ SuppressWarnings ("unchecked" )
2629 public void interceptTest () throws IOException {
2730 final String expectedHeader = TelemetryHandler .GRAPH_VERSION_PREFIX +"/"
2831 +TelemetryHandler .VERSION ;
29- final OkHttpClient client = HttpClients .createDefault (mock (IAuthenticationProvider .class ));
32+ final IAuthenticationProvider authProvider = mock (IAuthenticationProvider .class );
33+ when (authProvider .getAuthorizationTokenAsync (any (URL .class ))).thenReturn (CompletableFuture .completedFuture ("" ));
34+ final OkHttpClient client = HttpClients .createDefault (authProvider );
3035 final Request request = new Request .Builder ().url ("https://graph.microsoft.com/v1.0/users/" ).build ();
3136 final Response response = client .newCall (request ).execute ();
3237 assertNotNull (response );
@@ -36,10 +41,10 @@ public void interceptTest() throws IOException {
3641 }
3742
3843 @ Test
39- @ SuppressWarnings ("unchecked" )
4044 public void arrayInterceptorsTest () throws IOException {
41-
42- final AuthenticationHandler authenticationHandler = new AuthenticationHandler (mock (IAuthenticationProvider .class ));
45+ final IAuthenticationProvider authProvider = mock (IAuthenticationProvider .class );
46+ when (authProvider .getAuthorizationTokenAsync (any (URL .class ))).thenReturn (CompletableFuture .completedFuture ("" ));
47+ final AuthenticationHandler authenticationHandler = new AuthenticationHandler (authProvider );
4348 final Interceptor [] interceptors = {new RetryHandler (), new RedirectHandler (), authenticationHandler };
4449 final OkHttpClient client = HttpClients .createFromInterceptors (interceptors );
4550 final String expectedHeader = TelemetryHandler .GRAPH_VERSION_PREFIX +"/"
0 commit comments