Package com.atlassian.bamboo.testutils
Class ResultSetMockBuilder
java.lang.Object
com.atlassian.bamboo.testutils.ResultSetMockBuilder
A builder used to create mocks of SQL
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddColumnValue
(@NotNull String columnName, @Nullable Object value) Adds next column value to the current row of the mockedResultSet
and assigns the column name to it.addColumnValue
(@Nullable Object value) Adds next column value to the current row of the mockedResultSet
.addRow()
Adds next row to the mockedResultSet
.build()
Builds the mock ofResultSet
.
-
Constructor Details
-
ResultSetMockBuilder
public ResultSetMockBuilder()
-
-
Method Details
-
addRow
Adds next row to the mockedResultSet
. -
addColumnValue
Adds next column value to the current row of the mockedResultSet
.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. -
addColumnValue
public ResultSetMockBuilder addColumnValue(@NotNull @NotNull String columnName, @Nullable @Nullable Object value) Adds next column value to the current row of the mockedResultSet
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. -
build
Builds the mock ofResultSet
.
-