SimpleTokenManager implements TokenManager { @Override public SignedJWT generateUnauthToken() { try { return mobiTokenVerifier.generateToken("anon", ISSUER, ANON_SCOPE, tokenDuration, null); } catch (JOSEException e) { String msg = "Problem Creating JWT Token"; LOG.error(msg, e); throw new MobiException(e); } }  @Activate void start(Map<String, Object> props); @Modified void modified(Map<String, Object> props); @Override Optional<SignedJWT> verifyToken(String tokenString); @Override SignedJWT generateUnauthToken(); @Override SignedJWT generateAuthToken(String username); @Override String getTokenString(ContainerRequestContext requestContext); @Override String getTokenString(HttpServletRequest servletRequest); @Override Cookie createSecureTokenCookie(SignedJWT token); @Override NewCookie createSecureTokenNewCookie(SignedJWT token);  }
@Test public void generateUnauthTokenTest() throws Exception { SignedJWT result = manager.generateUnauthToken(); assertEquals(jwt, result); verify(mobiTokenVerifier).generateToken("anon", SimpleTokenManager.ISSUER, SimpleTokenManager.ANON_SCOPE, 86400000, null); }
@Test public void generateUnauthTokenExceptionTest() throws Exception { when(mobiTokenVerifier.generateToken(anyString(), anyString(), anyString(), anyLong(), any(Map.class))).thenThrow(new JOSEException("")); thrown.expect(MobiException.class); SignedJWT result = manager.generateUnauthToken(); assertEquals(jwt, result); verify(mobiTokenVerifier).generateToken("anon", SimpleTokenManager.ISSUER, SimpleTokenManager.ANON_SCOPE, 86400000, null); }