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 MockQueryExecutionInfo
empty()
Provide an emptyMockMethodExecutionInfo
.int
Get the size of the batch query.int
Get the number of the binding.Get the associatedConnectionInfo
.Mapped query result available for each-query-result-callback(ProxyExecutionListener.eachQueryResult(QueryExecutionInfo)
).int
Represent NthResult
.Get the time that took queries to execute.Get the invoked query executionMethod
.Object[]
Get the arguments of the invocation.Get the proxy event type for query execution.Get the list ofQueryInfo
.long
Get the currently executed thread ID.Get the currently executed thread name.Get the thrown exception.getType()
Get the type of query execution.RetrieveValueStore
which is associated to the scope of before/after method execution.boolean
Indicate whether the query execution was successful or not.
-
Method Details
-
builder
Provides a builder forMockQueryExecutionInfo
.- Returns:
- builder
-
empty
Provide an emptyMockMethodExecutionInfo
.- Returns:
- a
MockMethodExecutionInfo
.
-
getMethod
Description copied from interface:QueryExecutionInfo
Get the invoked query executionMethod
.- Specified by:
getMethod
in interfaceQueryExecutionInfo
- Returns:
- invoked method
-
getMethodArgs
Description copied from interface:QueryExecutionInfo
Get the arguments of the invocation. This can benull
when method is invoked with no argument.- Specified by:
getMethodArgs
in interfaceQueryExecutionInfo
- Returns:
- argument lists or
null
if the invoked method did not take any arguments
-
getThrowable
Description copied from interface:QueryExecutionInfo
Get the thrown exception. ForProxyExecutionListener.beforeQuery(QueryExecutionInfo)
callback or query execution did't throw any error, this returnsnull
.- Specified by:
getThrowable
in interfaceQueryExecutionInfo
- Returns:
- thrown exception
-
getConnectionInfo
Description copied from interface:QueryExecutionInfo
Get the associatedConnectionInfo
.- Specified by:
getConnectionInfo
in interfaceQueryExecutionInfo
- Returns:
- connection info
-
isSuccess
public boolean isSuccess()Description copied from interface:QueryExecutionInfo
Indicate whether the query execution was successful or not. Contains valid value only after the query execution. Query execution is considered successful when thePublisher
returned fromStatement.execute()
either received completion or at least one element is emitted regardless of it has received cancellation.- Specified by:
isSuccess
in interfaceQueryExecutionInfo
- Returns:
- true when query has successfully executed
-
getBatchSize
public int getBatchSize()Description copied from interface:QueryExecutionInfo
Get the size of the batch query. i.e. Number of the calls ofBatch.add(String)
.- Specified by:
getBatchSize
in interfaceQueryExecutionInfo
- Returns:
- batch size
-
getQueries
Description copied from interface:QueryExecutionInfo
Get the list ofQueryInfo
.- Specified by:
getQueries
in interfaceQueryExecutionInfo
- Returns:
- list of queries. This will NOT return
null
.
-
getType
Description copied from interface:QueryExecutionInfo
Get the type of query execution.- Specified by:
getType
in interfaceQueryExecutionInfo
- Returns:
- type of query execution
-
getBindingsSize
public int getBindingsSize()Description copied from interface:QueryExecutionInfo
Get the number of the binding. i.e. Number of the calls ofStatement.add()
.- Specified by:
getBindingsSize
in interfaceQueryExecutionInfo
- Returns:
- size of the binding
-
getExecuteDuration
Description copied from interface:QueryExecutionInfo
Get the time that took queries to execute.Duration is only populated in appropriate phase. (e.g.:
ProxyExecutionListener.afterQuery(QueryExecutionInfo)
)- Specified by:
getExecuteDuration
in interfaceQueryExecutionInfo
- Returns:
- query execution duration
-
getThreadName
Description copied from interface:QueryExecutionInfo
Get the currently executed thread name.- Specified by:
getThreadName
in interfaceQueryExecutionInfo
- Returns:
- thread name
-
getThreadId
public long getThreadId()Description copied from interface:QueryExecutionInfo
Get the currently executed thread ID.- Specified by:
getThreadId
in interfaceQueryExecutionInfo
- Returns:
- thread ID
-
getProxyEventType
Description copied from interface:QueryExecutionInfo
Get the proxy event type for query execution.- Specified by:
getProxyEventType
in 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:QueryExecutionInfo
Represent NthResult
. On each query result callback(ProxyExecutionListener.eachQueryResult(QueryExecutionInfo)
), this value indicates NthResult
starting from 1. (1st query result, 2nd query result, 3rd, 4th,...). This returns 0 for before query execution(ProxyExecutionListener.beforeQuery(QueryExecutionInfo)
). For after query execution(ProxyExecutionListener.afterQuery(QueryExecutionInfo)
), this returns total number ofResult
returned by this query execution.- Specified by:
getCurrentResultCount
in interfaceQueryExecutionInfo
- Returns:
- Nth number of query result
-
getCurrentMappedResult
Description copied from interface:QueryExecutionInfo
Mapped query result available for each-query-result-callback(ProxyExecutionListener.eachQueryResult(QueryExecutionInfo)
). For before and after query execution(ProxyExecutionListener.beforeQuery(QueryExecutionInfo)
andProxyExecutionListener.afterQuery(QueryExecutionInfo)
), this returnsnull
.- Specified by:
getCurrentMappedResult
in interfaceQueryExecutionInfo
- Returns:
- currently mapped result
-
getValueStore
Description copied from interface:QueryExecutionInfo
RetrieveValueStore
which is associated to the scope of before/after method execution. Mainly used for passing values betweenProxyExecutionListener.beforeQuery(QueryExecutionInfo)
andProxyExecutionListener.afterQuery(QueryExecutionInfo)
.- Specified by:
getValueStore
in interfaceQueryExecutionInfo
- Returns:
- value store
-