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>
answers
private static long
serialVersionUID
private Strictness
strictness
private DescribedInvocation
usedAt
private java.lang.Object
usedAtLock
-
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 void
addAnswer(Answer answer)
java.lang.Object
answer(InvocationOnMock invocation)
Strictness
getStrictness()
Informs about theStrictness
level of this stubbing.void
markStubUsed(DescribedInvocation usedAt)
java.lang.String
toString()
Describes the invocation in the human friendly way.boolean
wasUsed()
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:Stubbing
Informs 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:DescribedInvocation
Describes the invocation in the human friendly way.- Specified by:
toString
in interfaceDescribedInvocation
- Overrides:
toString
in classInvocationMatcher
- Returns:
- the description of this invocation.
-
getStrictness
public Strictness getStrictness()
Description copied from interface:Stubbing
Informs about theStrictness
level of this stubbing. For more information about setting strictness for stubbings seeMockito.lenient()
.- Specified by:
getStrictness
in interfaceStubbing
-
-