JDBCSSHRecordStoreConnection implements SSHRecordStoreConnection { @Override public int deleteExpiredSSHCertRecords(int expiryTimeMins) { int affectedRows; final String caller = "deleteExpiredSSHCertRecords"; if (expiryTimeMins <= 0) { return 0; } try (PreparedStatement ps = con.prepareStatement(SQL_DELETE_EXPIRED_X509_RECORDS)) { ps.setInt(1, expiryTimeMins); affectedRows = executeUpdate(ps, caller); } catch (SQLException ex) { throw sqlError(ex, caller); } return affectedRows; } JDBCSSHRecordStoreConnection(Connection con); @Override void setOperationTimeout(int queryTimeout); @Override void close(); @Override SSHCertRecord getSSHCertRecord(String instanceId, String service); @Override boolean updateSSHCertRecord(SSHCertRecord sshCertRecord); @Override boolean insertSSHCertRecord(SSHCertRecord sshCertRecord); @Override boolean deleteSSHCertRecord(String instanceId, String service); @Override int deleteExpiredSSHCertRecords(int expiryTimeMins); static final String DB_COLUMN_INSTANCE_ID; static final String DB_COLUMN_SERVICE; static final String DB_COLUMN_CLIENT_IP; static final String DB_COLUMN_PRIVATE_IP; static final String DB_COLUMN_PRINCIPALS; }
@Test public void testdeleteExpiredSSHCertRecords() throws Exception { JDBCSSHRecordStoreConnection jdbcConn = new JDBCSSHRecordStoreConnection(mockConn); Mockito.doReturn(1).when(mockPrepStmt).executeUpdate(); jdbcConn.deleteExpiredSSHCertRecords(360); Mockito.verify(mockPrepStmt, times(1)).setInt(1, 360); jdbcConn.close(); }