Package org.jmock.internal
Class InvocationExpectation
- java.lang.Object
-
- org.jmock.internal.InvocationExpectation
-
- All Implemented Interfaces:
org.hamcrest.SelfDescribing,Expectation
public class InvocationExpectation extends Object implements Expectation
An expectation of zero or more matching invocations.- Author:
- npryce, smgf
-
-
Constructor Summary
Constructors Constructor Description InvocationExpectation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOrderingConstraint(OrderingConstraint orderingConstraint)voidaddSideEffect(SideEffect sideEffect)booleanallowsMoreInvocations()Can moreInvocations expected by this Expectation still occur?voiddescribeMismatch(Invocation invocation, org.hamcrest.Description description)voiddescribeTo(org.hamcrest.Description description)Objectinvoke(Invocation invocation)Invokes the expectation: records that the invocation has occurred and fakes some behaviour in response.booleanisSatisfied()Have enoughInvocations expected by this Expectation occurred?booleanmatches(Invocation invocation)Can the Expectation be invoked with invocation?voidsetAction(Action action)voidsetCardinality(Cardinality cardinality)voidsetDefaultAction(Action action)voidsetMethod(Method method)voidsetMethodMatcher(org.hamcrest.Matcher<? super Method> matcher)voidsetObjectMatcher(org.hamcrest.Matcher<?> objectMatcher)voidsetParametersMatcher(ParametersMatcher parametersMatcher)
-
-
-
Method Detail
-
setCardinality
public void setCardinality(Cardinality cardinality)
-
setObjectMatcher
public void setObjectMatcher(org.hamcrest.Matcher<?> objectMatcher)
-
setMethod
public void setMethod(Method method)
-
setMethodMatcher
public void setMethodMatcher(org.hamcrest.Matcher<? super Method> matcher)
-
setParametersMatcher
public void setParametersMatcher(ParametersMatcher parametersMatcher)
-
addOrderingConstraint
public void addOrderingConstraint(OrderingConstraint orderingConstraint)
-
addSideEffect
public void addSideEffect(SideEffect sideEffect)
-
setAction
public void setAction(Action action)
-
setDefaultAction
public void setDefaultAction(Action action)
-
describeTo
public void describeTo(org.hamcrest.Description description)
- Specified by:
describeToin interfaceorg.hamcrest.SelfDescribing
-
describeMismatch
public void describeMismatch(Invocation invocation, org.hamcrest.Description description)
- Specified by:
describeMismatchin interfaceExpectation
-
isSatisfied
public boolean isSatisfied()
Description copied from interface:ExpectationHave enoughInvocations expected by this Expectation occurred?- Specified by:
isSatisfiedin interfaceExpectation- Returns:
trueif the expectation has received enough of its expected invocations,falseotherwise.
-
allowsMoreInvocations
public boolean allowsMoreInvocations()
Description copied from interface:ExpectationCan moreInvocations expected by this Expectation still occur?- Specified by:
allowsMoreInvocationsin interfaceExpectation- Returns:
trueif invocations expected by this expectation can still occur,falseotherwise.
-
matches
public boolean matches(Invocation invocation)
Description copied from interface:ExpectationCan the Expectation be invoked with invocation?- Specified by:
matchesin interfaceExpectation- Parameters:
invocation- to be matched- Returns:
trueif the expectation can be invoked with invocation,falseotherwise.
-
invoke
public Object invoke(Invocation invocation) throws Throwable
Description copied from interface:ExpectationInvokes the expectation: records that the invocation has occurred and fakes some behaviour in response.- Specified by:
invokein interfaceExpectation- Parameters:
invocation- The invocation to record and fake.- Returns:
- A result that is eventually returned from the method call that caused the invocation.
- Throws:
Throwable- An exception that is eventually thrown from the method call that caused the invocation.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 mocked
-
-