public class ResultSetMockBuilder extends Object
ResultSet
.
Example usage:
// with named columns final ResultSet fetchRowsResult = new ResultSetMockBuilder() .addRow() .addColumnValue("name", "John") .addColumnValue("age", 21) .addRow() .addColumnValue("name", "James") .addColumnValue("age", "30") .build(); // with indexed columns final ResultSet countRowsResult = new ResultSetMockBuilder() .addRow() .addColumnValue(totalRows) .build();
Constructor and Description |
---|
ResultSetMockBuilder() |
Modifier and Type | Method and Description |
---|---|
ResultSetMockBuilder |
addColumnValue(Object value)
Adds next column value to the current row of the mocked
ResultSet . |
ResultSetMockBuilder |
addColumnValue(String columnName,
Object value)
Adds next column value to the current row of the mocked
ResultSet and assigns the column name to it. |
ResultSetMockBuilder |
addRow()
Adds next row to the mocked
ResultSet . |
ResultSet |
build()
Builds the mock of
ResultSet . |
public ResultSetMockBuilder addRow()
ResultSet
.public ResultSetMockBuilder addColumnValue(@Nullable Object value)
ResultSet
.
Calling this method will not assign a column name to this value, so retrieval from the result set will only be
possible by fetching by column index. Remember that column indexing for the ResultSet
starts from 1, and
not from 0.
Note: at least one row must be added by calling addRow()
prior to adding column values.
public ResultSetMockBuilder addColumnValue(@NotNull String columnName, @Nullable Object value)
ResultSet
and assigns the column name to it.
Retrieval of this value will be possible both by column index and by column name. Remember that column indexing
for the ResultSet
starts from 1, and not from 0.
Note: at least one row must be added by calling addRow()
prior to adding column values.
Copyright © 2020 Atlassian Software Systems Pty Ltd. All rights reserved.