@FunctionalInterface public interface MockDataProvider
Supply this data provider to your
MockConnection in order to globally
provide data for SQL statements.
execute(MockExecuteContext) for details.
|Modifier and Type||Method and Description|
Execution callback for a JDBC query execution.
MockResult execute(MockExecuteContext ctx) throws SQLException
This callback will be called by
MockStatement upon the various
statement execution methods. These include:
The various execution modes are unified into this simple method. Implementations should adhere to this contract:
MockStatementdoes not distinguish between "static" and "prepared" statements. However, a non-empty
MockExecuteContext.bindings()is a strong indicator for a
MockStatementdoes not distinguish between "batch" and "single" statements. However...
MockExecuteContext.batchSQL()with more than one SQL string is a strong indicator for a "multi-batch statement", as understood by jOOQ's
MockExecuteContext.batchBindings()with more than one bind variable array is a strong indicator for a "single-batch statement", as understood by jOOQ's
MockResultobjects as batch executions. In other words, you should guarantee that:
int multiSize = context.getBatchSQL().length;
int singleSize = context.getBatchBindings().length;
assertEquals(result.length, Math.max(multiSize, singleSize))
This holds true also for non-batch executions (where both sizes are equal
Statement.RETURN_GENERATED_KEYS) are requested from this execution, you can also add
MockResult.datato your result, in addition to the affected
MockResult.rows. The relevant flag is passed from
MockStatementto any of these properties:
Record. If OUT parameters are requested, implementors must ensure the presence of such a
ctx- The execution context.
SQLExceptionthat is passed through to jOOQ.
Copyright © 2016. All Rights Reserved.