### Question:
DbTokenStore implements TokenStore { public List<DbAccessToken> findTokensByUserName(String userName) { return (List<DbAccessToken>)dbAccessTokenRepository.findByUsername(userName); } DbTokenStore(DbAccessTokenRepository cbAccessTokenRepository, DbRefreshTokenRepository cbRefreshTokenRepository); @Override OAuth2Authentication readAuthentication(OAuth2AccessToken accessToken); @Override OAuth2Authentication readAuthentication(String token); @Override void storeAccessToken(OAuth2AccessToken accessToken, OAuth2Authentication authentication); @Override OAuth2AccessToken readAccessToken(String tokenValue); @Override void removeAccessToken(OAuth2AccessToken oAuth2AccessToken); @Override void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication); @Override OAuth2RefreshToken readRefreshToken(String tokenValue); @Override OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken refreshToken); @Override void removeRefreshToken(OAuth2RefreshToken refreshToken); @Override void removeAccessTokenUsingRefreshToken(OAuth2RefreshToken refreshToken); @Override OAuth2AccessToken getAccessToken(OAuth2Authentication authentication); @Override Collection<OAuth2AccessToken> findTokensByClientIdAndUserName(String clientId, String userName); @Override Collection<OAuth2AccessToken> findTokensByClientId(String clientId); List<DbAccessToken> findTokensByUserName(String userName); void revokeAccessToken(String clientId, String username);  }### Answer:
@Test public void test_findTokensByUserName_userFound() { String username = "name"; List<DbAccessToken> dbAccessTokenList = new ArrayList<>(); DbAccessToken token = new DbAccessToken(); dbAccessTokenList.add(token); Mockito.when(dbAccessTokenRepository.findByUsername(username)).thenReturn(dbAccessTokenList); Assert.assertEquals(token, managerToTest.findTokensByUserName(username).get(0)); }
@Test public void test_findTokensByUserName_userNotFound() { String username = "name"; List<DbAccessToken> dbAccessTokenList = new ArrayList<>(); Mockito.when(dbAccessTokenRepository.findByUsername(username)).thenReturn(dbAccessTokenList); Assert.assertEquals(dbAccessTokenList, managerToTest.findTokensByUserName(username)); }