@Test public void shouldUseManagerToCreateSSOToken() throws SSOException { String key = "badger"; SSOTokenManager mockManager = mock(SSOTokenManager.class); SSOTokenFactory tokenFactory = new SSOTokenFactory(mockManager); tokenFactory.getTokenFromId(key); verify(mockManager).createSSOToken(eq(key)); }
public SSOToken getTokenFromId(String tokenId) { if (StringUtils.isEmpty(tokenId)) { return null; } if (debug.messageEnabled()) { debug.message("Creating SSOToken for ID: " + tokenId); } try { return manager.createSSOToken(tokenId); } catch (SSOException e) { debug.warning("Failed to create SSO Token for ID: " + tokenId, e); return null; } }
SSOTokenFactory { public SSOToken getTokenFromId(String tokenId) { if (StringUtils.isEmpty(tokenId)) { return null; } if (debug.messageEnabled()) { debug.message("Creating SSOToken for ID: " + tokenId); } try { return manager.createSSOToken(tokenId); } catch (SSOException e) { debug.warning("Failed to create SSO Token for ID: " + tokenId, e); return null; } } }
SSOTokenFactory { public SSOToken getTokenFromId(String tokenId) { if (StringUtils.isEmpty(tokenId)) { return null; } if (debug.messageEnabled()) { debug.message("Creating SSOToken for ID: " + tokenId); } try { return manager.createSSOToken(tokenId); } catch (SSOException e) { debug.warning("Failed to create SSO Token for ID: " + tokenId, e); return null; } } @Inject  SSOTokenFactory(SSOTokenManager manager);  SSOTokenFactory(SSOTokenManager manager, Debug debug); }
SSOTokenFactory { public SSOToken getTokenFromId(String tokenId) { if (StringUtils.isEmpty(tokenId)) { return null; } if (debug.messageEnabled()) { debug.message("Creating SSOToken for ID: " + tokenId); } try { return manager.createSSOToken(tokenId); } catch (SSOException e) { debug.warning("Failed to create SSO Token for ID: " + tokenId, e); return null; } } @Inject  SSOTokenFactory(SSOTokenManager manager);  SSOTokenFactory(SSOTokenManager manager, Debug debug); SSOToken getTokenFromId(String tokenId); boolean isTokenValid(SSOToken token); SSOToken getAdminToken(); }
SSOTokenFactory { public SSOToken getTokenFromId(String tokenId) { if (StringUtils.isEmpty(tokenId)) { return null; } if (debug.messageEnabled()) { debug.message("Creating SSOToken for ID: " + tokenId); } try { return manager.createSSOToken(tokenId); } catch (SSOException e) { debug.warning("Failed to create SSO Token for ID: " + tokenId, e); return null; } } @Inject  SSOTokenFactory(SSOTokenManager manager);  SSOTokenFactory(SSOTokenManager manager, Debug debug); SSOToken getTokenFromId(String tokenId); boolean isTokenValid(SSOToken token); SSOToken getAdminToken();  }