org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs 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
Mock objects library for java
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.stubbing.defaultanswers;
import org.mockito.MockSettings;
import org.mockito.Mockito;
import org.mockito.internal.InternalMockHandler;
import org.mockito.internal.MockitoCore;
import org.mockito.internal.creation.settings.CreationSettings;
import org.mockito.internal.stubbing.InvocationContainerImpl;
import org.mockito.internal.stubbing.StubbedInvocationMatcher;
import org.mockito.internal.util.MockUtil;
import org.mockito.internal.util.reflection.GenericMetadataSupport;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.mock.MockCreationSettings;
import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.io.Serializable;
import static org.mockito.Mockito.withSettings;
/**
* Returning deep stub implementation.
*
* Will return previously created mock if the invocation matches.
*
* Supports nested generic information, with this answer you can write code like this :
*
*
* interface GenericsNest<K extends Comparable<K> & Cloneable> extends Map<K, Set<Number>> {}
*
* GenericsNest<?> mock = mock(GenericsNest.class, new ReturnsGenericDeepStubs());
* Number number = mock.entrySet().iterator().next().getValue().iterator().next();
*
*
*
* @see org.mockito.Mockito#RETURNS_DEEP_STUBS
* @see org.mockito.Answers#RETURNS_DEEP_STUBS
*/
public class ReturnsDeepStubs implements Answer