### Question:
JdbcMetadataBuilder implements MetadataBuilder<Connection>,
        ParametrizedMetadataBuilder<Connection, PartialMetadataOptions> { protected void setResult(List<String> result, ResultSet resultSet) throws SQLException { RowSetFactory aFactory = RowSetProvider.newFactory(); CachedRowSet cachedRowSet = aFactory.createCachedRowSet(); cachedRowSet.populate(resultSet); ResultSetWrappingSqlRowSet resultSetWrappingSqlRowSet = getResultSetWrappingSqlRowSet(cachedRowSet); if (resultSetWrappingSqlRowSet.isBeforeFirst()) { while (resultSetWrappingSqlRowSet.next()) { result.add(resultSetWrappingSqlRowSet.getString("TABLE_SCHEM")); } } cachedRowSet.close(); }  @Override SchemaElement build(Connection connection, PartialMetadataOptions options); SchemaElement build(Connection connection, Map<String, String[]> options); void setCharacterEscape(SpecialCharacterEscape characterEscape); static final String GROUP_KIND_SCHEMA; static final String GROUP_KIND_DATASOURCE; }### Answer:
@Test (expectedExceptions = InvalidResultSetAccessException.class) public void setResult_validateIsBeforeFirst() throws SQLException { List<String> result = new ArrayList<>(); List<String> expectedResult = new ArrayList<>(); final Connection connection = mock(Connection.class); final Statement statement = mock(Statement.class); doReturn(statement).when(connection).createStatement(); final ResultSet resultSet = mock(ResultSet.class); final ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class); doReturn(resultSetMetaData).when(resultSet).getMetaData(); doReturn(true).when(resultSet).isBeforeFirst(); doReturn(true).doReturn(false).when(resultSet).next(); doReturn(1).when(resultSetMetaData).getColumnCount(); doReturn("public").when(resultSet).getString("TABLE_SCHEM"); jdbcMetadataBuilder.setResult(result, resultSet); }