### Question:
RowMapper { public static String getSqlRedo(TransactionalBufferMetrics metrics, ResultSet rs) { int lobLimitCounter = 9; StringBuilder result = new StringBuilder(4000); try { String redo_sql = rs.getString(SQL_REDO); if (redo_sql == null) { return null; } result = new StringBuilder(redo_sql); int csf = rs.getInt(CSF); while (csf == 1) { rs.next(); if (lobLimitCounter-- == 0) { LOGGER.warn("LOB value was truncated due to the connector limitation of {} MB", 40); break; } result.append(rs.getString(SQL_REDO)); csf = rs.getInt(CSF); } } catch (SQLException e) { logError(metrics, e, "SQL_REDO"); } return result.toString(); }  static String getOperation(TransactionalBufferMetrics metrics, ResultSet rs); static String getUsername(TransactionalBufferMetrics metrics, ResultSet rs); static int getOperationCode(TransactionalBufferMetrics metrics, ResultSet rs); static String getTableName(TransactionalBufferMetrics metrics, ResultSet rs); static String getSegOwner(TransactionalBufferMetrics metrics, ResultSet rs); static Timestamp getChangeTime(TransactionalBufferMetrics metrics, ResultSet rs); static BigDecimal getScn(TransactionalBufferMetrics metrics, ResultSet rs); static String getTransactionId(TransactionalBufferMetrics metrics, ResultSet rs); static String getSqlRedo(TransactionalBufferMetrics metrics, ResultSet rs); static TableId getTableId(String catalogName, ResultSet rs); static final int INSERT; static final int DELETE; static final int UPDATE; static final int DDL; static final int COMMIT; static final int MISSING_SCN; static final int ROLLBACK; }### Answer:
@Test public void testSqlRedo() throws SQLException { Mockito.when(rs.getInt(6)).thenReturn(0); Mockito.when(rs.getString(2)).thenReturn("short_sql"); String sql = RowMapper.getSqlRedo(metrics, rs); assertThat(sql.equals("short_sql")).isTrue(); verify(rs).getInt(6); verify(rs).getString(2); Mockito.when(rs.getInt(6)).thenReturn(1).thenReturn(0); Mockito.when(rs.getString(2)).thenReturn("long").thenReturn("_sql"); sql = RowMapper.getSqlRedo(metrics, rs); assertThat(sql.equals("long_sql")).isTrue(); verify(rs, times(3)).getInt(6); verify(rs, times(3)).getString(2); char[] chars = new char[4000]; Arrays.fill(chars, 'a'); Mockito.when(rs.getString(2)).thenReturn(new String(chars)); Mockito.when(rs.getInt(6)).thenReturn(1); sql = RowMapper.getSqlRedo(metrics, rs); assertThat(sql.length() == 40_000).isTrue(); verify(rs, times(13)).getInt(6); verify(rs, times(13)).getString(2); Mockito.when(rs.getInt(6)).thenReturn(0); Mockito.when(rs.getString(2)).thenReturn(null); sql = RowMapper.getSqlRedo(metrics, rs); assertThat(sql == null).isTrue(); verify(rs, times(13)).getInt(6); verify(rs, times(14)).getString(2); Mockito.when(rs.getInt(6)).thenReturn(0); Mockito.when(rs.getString(2)).thenThrow(SQLException.class); sql = RowMapper.getSqlRedo(metrics, rs); assertThat(sql.equals("")).isTrue(); verify(rs, times(13)).getInt(6); verify(rs, times(15)).getString(2); }