@Test void testExecute() { OAuth2AccessToken expiredToken = mock(OAuth2AccessToken.class); when(expiredToken.isExpired()).thenReturn(true); OAuth2AccessToken token = mock(OAuth2AccessToken.class); when(token.isExpired()).thenReturn(false); when(tokenStore.findTokensByClientId(anyString())).thenReturn(List.of(expiredToken, token)); cleaner.execute(null); verify(tokenStore).removeAccessToken(expiredToken); verify(tokenStore, never()).removeAccessToken(token); }
@Override public void execute(Date expirationTime) { Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(SecurityUtil.CLIENT_ID); LOGGER.debug(CleanUpJob.LOG_MARKER, Messages.REMOVING_EXPIRED_TOKENS_FROM_TOKEN_STORE); int removedTokens = removeTokens(tokens); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.REMOVED_TOKENS_0, removedTokens)); }
TokensCleaner implements Cleaner { @Override public void execute(Date expirationTime) { Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(SecurityUtil.CLIENT_ID); LOGGER.debug(CleanUpJob.LOG_MARKER, Messages.REMOVING_EXPIRED_TOKENS_FROM_TOKEN_STORE); int removedTokens = removeTokens(tokens); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.REMOVED_TOKENS_0, removedTokens)); } }
TokensCleaner implements Cleaner { @Override public void execute(Date expirationTime) { Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(SecurityUtil.CLIENT_ID); LOGGER.debug(CleanUpJob.LOG_MARKER, Messages.REMOVING_EXPIRED_TOKENS_FROM_TOKEN_STORE); int removedTokens = removeTokens(tokens); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.REMOVED_TOKENS_0, removedTokens)); } @Inject  TokensCleaner(@Named("tokenStore") TokenStore tokenStore); }
TokensCleaner implements Cleaner { @Override public void execute(Date expirationTime) { Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(SecurityUtil.CLIENT_ID); LOGGER.debug(CleanUpJob.LOG_MARKER, Messages.REMOVING_EXPIRED_TOKENS_FROM_TOKEN_STORE); int removedTokens = removeTokens(tokens); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.REMOVED_TOKENS_0, removedTokens)); } @Inject  TokensCleaner(@Named("tokenStore") TokenStore tokenStore); @Override void execute(Date expirationTime); }
TokensCleaner implements Cleaner { @Override public void execute(Date expirationTime) { Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(SecurityUtil.CLIENT_ID); LOGGER.debug(CleanUpJob.LOG_MARKER, Messages.REMOVING_EXPIRED_TOKENS_FROM_TOKEN_STORE); int removedTokens = removeTokens(tokens); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.REMOVED_TOKENS_0, removedTokens)); } @Inject  TokensCleaner(@Named("tokenStore") TokenStore tokenStore); @Override void execute(Date expirationTime);  }