Interface Expectation
- All Superinterfaces:
org.hamcrest.SelfDescribing
- All Known Implementing Classes:
InvocationExpectation
public interface Expectation
extends org.hamcrest.SelfDescribing
An object that matches, checks and fakes an
Invocation-
Method Summary
Modifier and TypeMethodDescriptionbooleanCan moreInvocations expected by this Expectation still occur?voiddescribeMismatch(Invocation invocation, org.hamcrest.Description description) invoke(Invocation invocation) Invokes the expectation: records that the invocation has occurred and fakes some behaviour in response.booleanHave enoughInvocations expected by this Expectation occurred?booleanmatches(Invocation invocation) Can the Expectation be invoked with invocation?Methods inherited from interface org.hamcrest.SelfDescribing
describeTo
-
Method Details
-
isSatisfied
boolean isSatisfied()Have enoughInvocations expected by this Expectation occurred?- Returns:
trueif the expectation has received enough of its expected invocations,falseotherwise.
-
allowsMoreInvocations
boolean allowsMoreInvocations()Can moreInvocations expected by this Expectation still occur?- Returns:
trueif invocations expected by this expectation can still occur,falseotherwise.
-
matches
Can the Expectation be invoked with invocation?- Parameters:
invocation- to be matched- Returns:
trueif the expectation can be invoked with invocation,falseotherwise.
-
describeMismatch
-
invoke
Invokes the expectation: records that the invocation has occurred and fakes some behaviour in response.- 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
-