Class ReturnsMoreEmptyValues
- java.lang.Object
-
- org.mockito.internal.stubbing.defaultanswers.ReturnsMoreEmptyValues
-
- All Implemented Interfaces:
java.io.Serializable
,Answer<java.lang.Object>
public class ReturnsMoreEmptyValues extends java.lang.Object implements Answer<java.lang.Object>, java.io.Serializable
It's likely this implementation will be used by default by every Mockito 4.0.0 mock.Currently used only by
Mockito.RETURNS_SMART_NULLS
Current version of Mockito mocks by default use
ReturnsEmptyValues
- Returns appropriate primitive for primitive-returning methods
- Returns consistent values for primitive wrapper classes (e.g. int-returning method returns 0 and Integer-returning method returns 0, too)
- Returns empty collection for collection-returning methods (works for most commonly used collection types)
- Returns empty array for array-returning methods
- Returns "" for String-returning method
- Returns description of mock for toString() method
- Returns non-zero for Comparable#compareTo(T other) method (see issue 184)
- Returns null for everything else
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Answer<java.lang.Object>
delegate
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ReturnsMoreEmptyValues()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
answer(InvocationOnMock invocation)
(package private) java.lang.Object
returnValueFor(java.lang.Class<?> type)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
delegate
private final Answer<java.lang.Object> delegate
-
-
Method Detail
-
answer
public java.lang.Object answer(InvocationOnMock invocation) throws java.lang.Throwable
-
returnValueFor
java.lang.Object returnValueFor(java.lang.Class<?> type)
-
-