Class MockQueryExecutionInfo
java.lang.Object
io.r2dbc.proxy.test.MockQueryExecutionInfo
- All Implemented Interfaces:
QueryExecutionInfo
Mock implementation of
QueryExecutionInfo for testing.- Author:
- Tadaya Tsuyukubo
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Provides a builder forMockQueryExecutionInfo.static MockQueryExecutionInfoempty()Provide an emptyMockMethodExecutionInfo.intReturns the size of the batch query.intReturns the number of bindings.Returns the associatedConnectionInfo.The mapped query result available for each query-result callback (ProxyExecutionListener.eachQueryResult(QueryExecutionInfo)).intRepresents the NthResult.Returns the time spent executing the query.Returns the method used for the query execution.Object[]Returns the arguments passed to the invocation.Returns the proxy event type for the query execution.Returns the list ofQueryInfo.longReturns the ID of the thread executing the query.Returns the name of the thread executing the query.Returns the exception thrown by the invocation.getType()Returns the type of query execution.Returns theValueStoreassociated with the scope of the before/after query execution.booleanReturns whether the query execution was successful.
-
Method Details
-
builder
Provides a builder forMockQueryExecutionInfo.- Returns:
- builder
-
empty
Provide an emptyMockMethodExecutionInfo.- Returns:
- a
MockMethodExecutionInfo.
-
getMethod
Description copied from interface:QueryExecutionInfoReturns the method used for the query execution.- Specified by:
getMethodin interfaceQueryExecutionInfo- Returns:
- invoked method
-
getMethodArgs
Description copied from interface:QueryExecutionInfoReturns the arguments passed to the invocation. This value may benullwhen the method is invoked without any arguments.- Specified by:
getMethodArgsin interfaceQueryExecutionInfo- Returns:
- argument lists or
nullif the invoked method did not take any arguments
-
getThrowable
Description copied from interface:QueryExecutionInfoReturns the exception thrown by the invocation. For theProxyExecutionListener.beforeQuery(QueryExecutionInfo)callback, or when the query execution did not throw any error, this returnsnull.- Specified by:
getThrowablein interfaceQueryExecutionInfo- Returns:
- thrown exception
-
getConnectionInfo
Description copied from interface:QueryExecutionInfoReturns the associatedConnectionInfo.- Specified by:
getConnectionInfoin interfaceQueryExecutionInfo- Returns:
- connection info
-
isSuccess
public boolean isSuccess()Description copied from interface:QueryExecutionInfoReturns whether the query execution was successful. This value is populated only after the query execution completes. A query execution is considered successful when thePublisherreturned fromStatement.execute()either received completion or at least one element is emitted regardless of it has received cancellation.- Specified by:
isSuccessin interfaceQueryExecutionInfo- Returns:
- true when query has successfully executed
-
getBatchSize
public int getBatchSize()Description copied from interface:QueryExecutionInfoReturns the size of the batch query. In other words, this is the number of calls toBatch.add(String).- Specified by:
getBatchSizein interfaceQueryExecutionInfo- Returns:
- batch size
-
getQueries
Description copied from interface:QueryExecutionInfoReturns the list ofQueryInfo.- Specified by:
getQueriesin interfaceQueryExecutionInfo- Returns:
- the list of queries; never
null
-
getType
Description copied from interface:QueryExecutionInfoReturns the type of query execution.- Specified by:
getTypein interfaceQueryExecutionInfo- Returns:
- type of query execution
-
getBindingsSize
public int getBindingsSize()Description copied from interface:QueryExecutionInfoReturns the number of bindings. In other words, this is the number of calls toStatement.add().- Specified by:
getBindingsSizein interfaceQueryExecutionInfo- Returns:
- size of the binding
-
getExecuteDuration
Description copied from interface:QueryExecutionInfoReturns the time spent executing the query.Duration is only populated in appropriate phase. (e.g.:
ProxyExecutionListener.afterQuery(QueryExecutionInfo))- Specified by:
getExecuteDurationin interfaceQueryExecutionInfo- Returns:
- query execution duration
-
getThreadName
Description copied from interface:QueryExecutionInfoReturns the name of the thread executing the query.- Specified by:
getThreadNamein interfaceQueryExecutionInfo- Returns:
- thread name
-
getThreadId
public long getThreadId()Description copied from interface:QueryExecutionInfoReturns the ID of the thread executing the query.- Specified by:
getThreadIdin interfaceQueryExecutionInfo- Returns:
- thread ID
-
getProxyEventType
Description copied from interface:QueryExecutionInfoReturns the proxy event type for the query execution.- Specified by:
getProxyEventTypein interfaceQueryExecutionInfo- Returns:
- proxy event type; one of
ProxyEventType.BEFORE_QUERY,ProxyEventType.AFTER_QUERY, orProxyEventType.EACH_QUERY_RESULT
-
getCurrentResultCount
public int getCurrentResultCount()Description copied from interface:QueryExecutionInfoRepresents the NthResult. For each query-result callback (ProxyExecutionListener.eachQueryResult(QueryExecutionInfo)), this value indicates the NthResult, starting from 1 (first, second, third, and so on). This returns 0 before query execution (ProxyExecutionListener.beforeQuery(QueryExecutionInfo)). For after-query execution (ProxyExecutionListener.afterQuery(QueryExecutionInfo)), it returns the total number ofResultobjects returned by this query execution.- Specified by:
getCurrentResultCountin interfaceQueryExecutionInfo- Returns:
- Nth number of query result
-
getCurrentMappedResult
Description copied from interface:QueryExecutionInfoThe mapped query result available for each query-result callback (ProxyExecutionListener.eachQueryResult(QueryExecutionInfo)). For the before- and after-query execution callbacks (ProxyExecutionListener.beforeQuery(QueryExecutionInfo)andProxyExecutionListener.afterQuery(QueryExecutionInfo)), this returnsnull.- Specified by:
getCurrentMappedResultin interfaceQueryExecutionInfo- Returns:
- currently mapped result
-
getValueStore
Description copied from interface:QueryExecutionInfoReturns theValueStoreassociated with the scope of the before/after query execution. Mainly used for passing values betweenProxyExecutionListener.beforeQuery(QueryExecutionInfo)andProxyExecutionListener.afterQuery(QueryExecutionInfo).- Specified by:
getValueStorein interfaceQueryExecutionInfo- Returns:
- value store
-