Package com.atlassian.bamboo.testutils
Class ResultSetMockBuilder
- java.lang.Object
-
- com.atlassian.bamboo.testutils.ResultSetMockBuilder
-
public class ResultSetMockBuilder extends Object
A builder used to create mocks of SQLResultSet
.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
Constructors Constructor Description ResultSetMockBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultSetMockBuilder
addColumnValue(@NotNull String columnName, @Nullable Object value)
Adds next column value to the current row of the mockedResultSet
and assigns the column name to it.ResultSetMockBuilder
addColumnValue(@Nullable Object value)
Adds next column value to the current row of the mockedResultSet
.ResultSetMockBuilder
addRow()
Adds next row to the mockedResultSet
.ResultSet
build()
Builds the mock ofResultSet
.
-
-
-
Method Detail
-
addRow
public ResultSetMockBuilder addRow()
Adds next row to the mockedResultSet
.
-
addColumnValue
public ResultSetMockBuilder addColumnValue(@Nullable @Nullable Object value)
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.
-
-