public class InvocationExpectation extends java.lang.Object implements Expectation
| Modifier and Type | Class and Description |
|---|---|
private static class |
InvocationExpectation.AnyParametersMatcher |
| Modifier and Type | Field and Description |
|---|---|
private Action |
action |
private boolean |
actionIsDefault |
private static ParametersMatcher |
ANY_PARAMETERS |
private Cardinality |
cardinality |
private int |
invocationCount |
private boolean |
methodIsKnownToBeVoid |
private org.hamcrest.Matcher<? super java.lang.reflect.Method> |
methodMatcher |
private org.hamcrest.Matcher<?> |
objectMatcher |
private java.util.List<OrderingConstraint> |
orderingConstraints |
private ParametersMatcher |
parametersMatcher |
private java.util.List<SideEffect> |
sideEffects |
| Constructor and Description |
|---|
InvocationExpectation() |
| Modifier and Type | Method and Description |
|---|---|
void |
addOrderingConstraint(OrderingConstraint orderingConstraint) |
void |
addSideEffect(SideEffect sideEffect) |
boolean |
allowsMoreInvocations()
Can more
Invocations expected by this Expectation still occur? |
private void |
describeExpectation(org.hamcrest.Description description) |
private void |
describeMethod(org.hamcrest.Description description) |
void |
describeMismatch(Invocation invocation,
org.hamcrest.Description description) |
private void |
describeSideEffects(org.hamcrest.Description description) |
void |
describeTo(org.hamcrest.Description description) |
java.lang.Object |
invoke(Invocation invocation)
Invokes the expectation: records that the invocation has
occurred and fakes some behaviour in response.
|
private boolean |
isInCorrectOrder() |
boolean |
isSatisfied()
Have enough
Invocations expected by this Expectation occurred? |
boolean |
matches(Invocation invocation)
Can the Expectation be invoked with invocation?
|
private void |
performSideEffects() |
void |
setAction(Action action) |
void |
setCardinality(Cardinality cardinality) |
void |
setDefaultAction(Action action) |
void |
setMethod(java.lang.reflect.Method method) |
void |
setMethodMatcher(org.hamcrest.Matcher<? super java.lang.reflect.Method> matcher) |
void |
setObjectMatcher(org.hamcrest.Matcher<?> objectMatcher) |
void |
setParametersMatcher(ParametersMatcher parametersMatcher) |
private boolean |
shouldSuppressActionDescription() |
private static ParametersMatcher ANY_PARAMETERS
private Cardinality cardinality
private org.hamcrest.Matcher<?> objectMatcher
private org.hamcrest.Matcher<? super java.lang.reflect.Method> methodMatcher
private boolean methodIsKnownToBeVoid
private ParametersMatcher parametersMatcher
private Action action
private boolean actionIsDefault
private java.util.List<OrderingConstraint> orderingConstraints
private java.util.List<SideEffect> sideEffects
private int invocationCount
public void setCardinality(Cardinality cardinality)
public void setObjectMatcher(org.hamcrest.Matcher<?> objectMatcher)
public void setMethod(java.lang.reflect.Method method)
public void setMethodMatcher(org.hamcrest.Matcher<? super java.lang.reflect.Method> matcher)
public void setParametersMatcher(ParametersMatcher parametersMatcher)
public void addOrderingConstraint(OrderingConstraint orderingConstraint)
public void addSideEffect(SideEffect sideEffect)
public void setAction(Action action)
public void setDefaultAction(Action action)
public void describeTo(org.hamcrest.Description description)
describeTo in interface org.hamcrest.SelfDescribingpublic void describeMismatch(Invocation invocation, org.hamcrest.Description description)
describeMismatch in interface Expectationprivate void describeExpectation(org.hamcrest.Description description)
private void describeMethod(org.hamcrest.Description description)
private void describeSideEffects(org.hamcrest.Description description)
private boolean shouldSuppressActionDescription()
public boolean isSatisfied()
ExpectationInvocations expected by this Expectation occurred?isSatisfied in interface Expectationtrue if the expectation has received enough
of its expected invocations, false otherwise.public boolean allowsMoreInvocations()
ExpectationInvocations expected by this Expectation still occur?allowsMoreInvocations in interface Expectationtrue if invocations expected by this expectation can still
occur, false otherwise.public boolean matches(Invocation invocation)
Expectationmatches in interface Expectationinvocation - to be matchedtrue if the expectation can be invoked with
invocation, false otherwise.private boolean isInCorrectOrder()
public java.lang.Object invoke(Invocation invocation) throws java.lang.Throwable
Expectationinvoke in interface Expectationinvocation - The invocation to record and fake.java.lang.Throwable - An exception that is eventually thrown from the method call
that caused the invocation.java.lang.IllegalStateException - The expectation has been invoked with a method that it doesn't
match or the faked behaviour has been set up incorrectly.
For example, IllegalStateException is thrown when trying to return
a value or throw a checked exception that is incompatible with the
return type of the method being mockedprivate void performSideEffects()