### Question:
OAuth2TokenDAO extends AbstractSearcherDAO implements IOAuth2TokenDAO { protected OAuth2AccessToken getAccessToken(final String token, Connection conn) { OAuth2AccessTokenImpl accessToken = null; PreparedStatement stat = null; ResultSet res = null; try { stat = conn.prepareStatement(SELECT_TOKEN); stat.setString(1, token); res = stat.executeQuery(); if (res.next()) { accessToken = new OAuth2AccessTokenImpl(token); accessToken.setRefreshToken(new DefaultOAuth2RefreshToken(res.getString("refreshtoken"))); accessToken.setClientId(res.getString("clientid")); accessToken.setGrantType(res.getString("granttype")); accessToken.setLocalUser(res.getString("localuser")); Timestamp timestamp = res.getTimestamp("expiresin"); Date expiration = new Date(timestamp.getTime()); accessToken.setExpiration(expiration); } } catch (Throwable t) { logger.error("Error loading token {}", token, t); throw new RuntimeException("Error loading token " + token, t); } finally { closeDaoResources(res, stat); } return accessToken; }  @Override List<OAuth2AccessToken> findTokensByClientIdAndUserName(String clientId, String username); @Override List<OAuth2AccessToken> findTokensByUserName(String username); @Override List<OAuth2AccessToken> findTokensByClientId(String clientId); @Override void storeAccessToken(OAuth2AccessToken accessToken, OAuth2Authentication authentication); @Override OAuth2AccessToken readAccessToken(final String accessToken); @Override void removeAccessToken(final String accessToken); @Override void removeAccessTokenUsingRefreshToken(String refreshToken); @Override void deleteExpiredToken(int expirationTime); @Override OAuth2RefreshToken readRefreshToken(String tokenValue); @Override OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken refreshToken);  }### Answer:
@Test public void getAccessToken() throws Exception { when(this.stat.executeQuery()).thenReturn(res); Mockito.when(res.next()).thenReturn(true).thenReturn(false); OAuth2AccessToken token = this.tokenDAO.readAccessToken("token"); Assert.assertNotNull(token); Mockito.verify(stat, Mockito.times(1)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(res, Mockito.times(4)).getString(Mockito.anyString()); Mockito.verify(res, Mockito.times(1)).getTimestamp(Mockito.anyString()); Mockito.verify(stat, Mockito.times(1)).close(); Mockito.verify(res, Mockito.times(1)).close(); Mockito.verify(conn, Mockito.times(1)).close(); }