### Question:
OAuth2TokenDAO extends AbstractSearcherDAO implements IOAuth2TokenDAO { @Override public void deleteExpiredToken(int expirationTime) { Connection conn = null; PreparedStatement stat = null; try { conn = this.getConnection(); conn.setAutoCommit(false); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, -expirationTime); stat = conn.prepareStatement(DELETE_EXPIRED_TOKENS); stat.setTimestamp(1, new Timestamp(calendar.getTimeInMillis())); stat.executeUpdate(); conn.commit(); } catch (Exception t) { this.executeRollback(conn); logger.error(ERROR_REMOVE_ACCESS_TOKEN, t); throw new RuntimeException(ERROR_REMOVE_ACCESS_TOKEN, t); } finally { closeDaoResources(null, stat, conn); } }  @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 deleteExpiredToken() throws Exception { this.tokenDAO.deleteExpiredToken(3600); Mockito.verify(stat, Mockito.times(1)).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); Mockito.verify(stat, Mockito.times(1)).close(); Mockito.verify(conn, Mockito.times(1)).close(); }
@Test(expected = RuntimeException.class) public void failDeleteExpiredToken() throws Exception { try { Mockito.doThrow(SQLException.class).when(stat).setTimestamp(Mockito.anyInt(), Mockito.any(Timestamp.class)); this.tokenDAO.deleteExpiredToken(3600); Assert.fail(); } catch (RuntimeException e) { Mockito.verify(stat, Mockito.times(1)).close(); Mockito.verify(conn, Mockito.times(1)).close(); throw e; } }