Package org.mockito.internal.stubbing
Class StubbedInvocationMatcher
- java.lang.Object
-
- org.mockito.internal.invocation.InvocationMatcher
-
- org.mockito.internal.stubbing.StubbedInvocationMatcher
-
- All Implemented Interfaces:
java.io.Serializable,DescribedInvocation,MatchableInvocation,Answer,Stubbing
public class StubbedInvocationMatcher extends InvocationMatcher implements java.io.Serializable, Stubbing
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Queue<Answer>answersprivate static longserialVersionUIDprivate Strictnessstrictnessprivate DescribedInvocationusedAtprivate java.lang.ObjectusedAtLock
-
Constructor Summary
Constructors Constructor Description StubbedInvocationMatcher(Answer answer, MatchableInvocation invocation, Strictness strictness)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnswer(Answer answer)java.lang.Objectanswer(InvocationOnMock invocation)StrictnessgetStrictness()Informs about theStrictnesslevel of this stubbing.voidmarkStubUsed(DescribedInvocation usedAt)java.lang.StringtoString()Describes the invocation in the human friendly way.booleanwasUsed()Informs if the stubbing was used-
Methods inherited from class org.mockito.internal.invocation.InvocationMatcher
captureArgumentsFrom, createFrom, getInvocation, getLocation, getMatchers, getMethod, hasSameMethod, hasSimilarMethod, matches
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.mockito.stubbing.Stubbing
getInvocation
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
answers
private final java.util.Queue<Answer> answers
-
strictness
private final Strictness strictness
-
usedAtLock
private final java.lang.Object usedAtLock
-
usedAt
private DescribedInvocation usedAt
-
-
Constructor Detail
-
StubbedInvocationMatcher
public StubbedInvocationMatcher(Answer answer, MatchableInvocation invocation, Strictness strictness)
-
-
Method Detail
-
answer
public java.lang.Object answer(InvocationOnMock invocation) throws java.lang.Throwable
-
addAnswer
public void addAnswer(Answer answer)
-
markStubUsed
public void markStubUsed(DescribedInvocation usedAt)
-
wasUsed
public boolean wasUsed()
Description copied from interface:StubbingInforms if the stubbing was usedWhat does it mean 'used stubbing'? Stubbing like
when(mock.foo()).thenReturn(true)is considered used when the methodmock.foo()is actually invoked during the execution of code under test.This method is used internally by Mockito to report and detect unused stubbings. Unused stubbings are dead code and should be deleted to increase clarity of tests (see
MockitoHint.To understand how this method is useful, see the description at
MockingDetails.getStubbings().
-
toString
public java.lang.String toString()
Description copied from interface:DescribedInvocationDescribes the invocation in the human friendly way.- Specified by:
toStringin interfaceDescribedInvocation- Overrides:
toStringin classInvocationMatcher- Returns:
- the description of this invocation.
-
getStrictness
public Strictness getStrictness()
Description copied from interface:StubbingInforms about theStrictnesslevel of this stubbing. For more information about setting strictness for stubbings seeMockito.lenient().- Specified by:
getStrictnessin interfaceStubbing
-
-