Class RetrieveGenericsForDefaultAnswers
java.lang.Object
org.mockito.internal.stubbing.defaultanswers.RetrieveGenericsForDefaultAnswers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Object
delegateChains
(Class<?> type) Try to resolve the result value usingReturnsEmptyValues
andReturnsMoreEmptyValues
.private static Class<?>
findTypeFromGeneric
(InvocationOnMock invocation, TypeVariable returnType) Retrieve the expected type when it came from a primitive.private static Class<?>
findTypeFromGenericInArguments
(InvocationOnMock invocation, TypeVariable returnType) Find a return type using generic arguments provided by the calling method.(package private) static Object
returnTypeForMockWithCorrectGenerics
(InvocationOnMock invocation, RetrieveGenericsForDefaultAnswers.AnswerCallback answerCallback)
-
Field Details
-
MOCKITO_CORE
-
-
Constructor Details
-
RetrieveGenericsForDefaultAnswers
private RetrieveGenericsForDefaultAnswers()
-
-
Method Details
-
returnTypeForMockWithCorrectGenerics
static Object returnTypeForMockWithCorrectGenerics(InvocationOnMock invocation, RetrieveGenericsForDefaultAnswers.AnswerCallback answerCallback) -
delegateChains
Try to resolve the result value usingReturnsEmptyValues
andReturnsMoreEmptyValues
. This will try to use all parent class (superclass & interfaces) to retrieve the value..- Parameters:
type
- the return type of the method- Returns:
- a non-null instance if the type has been resolve. Null otherwise.
-
findTypeFromGeneric
Retrieve the expected type when it came from a primitive. If the type cannot be retrieve, return null.- Parameters:
invocation
- the current invocationreturnType
- the expected return type- Returns:
- the type or null if not found
-
findTypeFromGenericInArguments
private static Class<?> findTypeFromGenericInArguments(InvocationOnMock invocation, TypeVariable returnType) Find a return type using generic arguments provided by the calling method.- Parameters:
invocation
- the current invocationreturnType
- the expected return type- Returns:
- the return type or null if the return type cannot be found
-