Class FluentAnswer<T extends org.camunda.bpm.engine.query.Query<?,R>,R>
java.lang.Object
org.camunda.community.mockito.answer.FluentAnswer<T,R>
- Type Parameters:
T- the return type of the answer
- All Implemented Interfaces:
org.mockito.stubbing.Answer<T>
public final class FluentAnswer<T extends org.camunda.bpm.engine.query.Query<?,R>,R>
extends Object
implements org.mockito.stubbing.Answer<T>
A fluent answer always returns the mock instance itself for all methods that
have the same return type as the mock instance. This makes it possible to
easily mock fluent-api behaviour without chaining the when/then stubbings or
relying on deep stubs.
-
Method Summary
Modifier and TypeMethodDescriptionanswer(org.mockito.invocation.InvocationOnMock invocation) Returns the mock itself if return type and mock type match (assume fluent api).static <T extends org.camunda.bpm.engine.query.Query<?,R>, R>
FluentAnswer<T,R> createAnswer(Class<T> type) Creates a new instance for the given type.static <T extends org.camunda.bpm.engine.query.Query<?,R>, R>
TcreateMock(Class<T> type) Creates a new mock of given type with a fluent default answer already set up.
-
Method Details
-
createMock
Creates a new mock of given type with a fluent default answer already set up.- Type Parameters:
T- generic parameter for type of mock- Parameters:
type- type of mock- Returns:
- new mock instance of type T with default fluent answer.
-
createAnswer
public static <T extends org.camunda.bpm.engine.query.Query<?,R>, FluentAnswer<T,R> R> createAnswer(Class<T> type) Creates a new instance for the given type.- Type Parameters:
T- generic parameter of the return type- Parameters:
type- the return type of the answer- Returns:
- new Answer that returns the mock itself
-
answer
Returns the mock itself if return type and mock type match (assume fluent api).- Specified by:
answerin interfaceorg.mockito.stubbing.Answer<T extends org.camunda.bpm.engine.query.Query<?,R>> - Parameters:
invocation- the method invocation. If its return type equals the mock type, just return the mock.- Returns:
- the mock itself or null (meaning further stubbing is required).
- Throws:
Throwable- when anything fails
-