Skip to content

Commit a017c5d

Browse files
committed
- fixes mocks after linting
1 parent b225b77 commit a017c5d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/test/java/com/microsoft/graph/httpcore/TelemetryHandlerTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
import static org.junit.jupiter.api.Assertions.assertNotNull;
44
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
import static org.mockito.ArgumentMatchers.any;
56
import static org.mockito.Mockito.mock;
7+
import static org.mockito.Mockito.when;
68

79
import java.io.IOException;
10+
import java.net.URL;
11+
import java.util.concurrent.CompletableFuture;
812

913
import com.microsoft.graph.authentication.IAuthenticationProvider;
1014
import 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

Comments
 (0)