AuthManager { public void tokenExpired(@NonNull String token) { synchronized (cachedAuthLock) { if (token.equals(cachedAuth.getToken())) { cachedAuth = null; } } } AuthManager(@NonNull AirshipRuntimeConfig runtimeConfig, @NonNull AirshipChannel channel); @VisibleForTesting  AuthManager(@NonNull AuthApiClient apiClient, @NonNull AirshipChannel channel, @NonNull Clock clock); @WorkerThread @NonNull String getToken(); void tokenExpired(@NonNull String token);  }
@Test public void tokenExpired() throws RequestException, AuthException { clock.currentTimeMillis = 0; when(mockChannel.getId()).thenReturn("channel id"); when(mockClient.getToken("channel id")) .thenReturn(new Response.Builder<AuthToken>(200) .setResult(new AuthToken("channel id", "some token", 100)) .build()) .thenReturn(new Response.Builder<AuthToken>(200) .setResult(new AuthToken("channel id", "some other token", 200)) .build()); assertEquals("some token", authManager.getToken()); authManager.tokenExpired("some token"); assertEquals("some other token", authManager.getToken()); }