org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-core Show documentation
Show all versions of mockito-core Show documentation
Mockito mock objects library core API and implementation
/*
* Copyright (c) 2016 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.stubbing.defaultanswers;
import org.mockito.internal.util.JavaEightUtil;
import org.mockito.internal.util.MockUtil;
import org.mockito.internal.util.Primitives;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.mock.MockName;
import org.mockito.stubbing.Answer;
import static org.mockito.internal.util.ObjectMethodsGuru.isCompareToMethod;
import static org.mockito.internal.util.ObjectMethodsGuru.isToStringMethod;
import java.io.Serializable;
import java.util.*;
/**
* Default answer of every Mockito mock.
*
* -
* 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 description of mock for toString() method
*
* -
* Returns zero if references are equals otherwise non-zero for Comparable#compareTo(T other) method (see issue 184)
*
* -
* Returns an {@code java.util.Optional#empty() empty Optional} for Optional. Similarly for primitive optional variants.
*
* -
* Returns an {@code java.util.stream.Stream#empty() empty Stream} for Stream. Similarly for primitive stream variants.
*
* -
* Returns null for everything else
*
*
*/
public class ReturnsEmptyValues implements Answer