AuthTokenManager implements TokenManager { @Override public String getAccessTokenString() { if (null == this.accessTokenResponse) { grantToken(); } else if (tokenExpired()) { refreshToken(); } return accessTokenResponse != null ? accessTokenResponse.getToken() : null; } AuthTokenManager(AuthSettings config); @Override void grantToken(); @Override String getAccessTokenString(); @Override String getRealm();  }
@Test public void testGetAccessTokenString() throws Exception { AccessTokenResponse response = mock(AccessTokenResponse.class); when(response.getToken()).thenReturn("token2"); this.tokenManager.accessTokenResponse = response; this.tokenManager.expirationTime = Long.MAX_VALUE; this.tokenManager.minTokenValidity = 0; String s = this.tokenManager.getAccessTokenString(); Assert.assertEquals("token2", s); }