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.
  • Field Details

    • ANY_PARAMETERS

      private static ParametersMatcher ANY_PARAMETERS
    • cardinality

      private Cardinality cardinality
    • objectMatcher

      private org.hamcrest.Matcher<?> objectMatcher
    • methodMatcher

      private org.hamcrest.Matcher<? super Method> methodMatcher
    • methodIsKnownToBeVoid

      private boolean methodIsKnownToBeVoid
    • parametersMatcher

      private ParametersMatcher parametersMatcher
    • action

      private Action action
    • actionIsDefault

      private boolean actionIsDefault
    • orderingConstraints

      private List<OrderingConstraint> orderingConstraints
    • sideEffects

      private List<SideEffect> sideEffects
    • invocationCount

      private int invocationCount
  • Constructor Details

    • InvocationExpectation

      public InvocationExpectation()
  • Method Details

    • 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:
      describeTo in interface org.hamcrest.SelfDescribing
    • describeMismatch

      public void describeMismatch(Invocation invocation, org.hamcrest.Description description)
      Specified by:
      describeMismatch in interface Expectation
    • describeExpectation

      private void describeExpectation(org.hamcrest.Description description)
    • describeMethod

      private void describeMethod(org.hamcrest.Description description)
    • describeSideEffects

      private void describeSideEffects(org.hamcrest.Description description)
    • shouldSuppressActionDescription

      private boolean shouldSuppressActionDescription()
    • isSatisfied

      public boolean isSatisfied()
      Description copied from interface: Expectation
      Have enough Invocations expected by this Expectation occurred?
      Specified by:
      isSatisfied in interface Expectation
      Returns:
      true if the expectation has received enough of its expected invocations, false otherwise.
    • allowsMoreInvocations

      public boolean allowsMoreInvocations()
      Description copied from interface: Expectation
      Can more Invocations expected by this Expectation still occur?
      Specified by:
      allowsMoreInvocations in interface Expectation
      Returns:
      true if invocations expected by this expectation can still occur, false otherwise.
    • matches

      public boolean matches(Invocation invocation)
      Description copied from interface: Expectation
      Can the Expectation be invoked with invocation?
      Specified by:
      matches in interface Expectation
      Parameters:
      invocation - to be matched
      Returns:
      true if the expectation can be invoked with invocation, false otherwise.
    • isInCorrectOrder

      private boolean isInCorrectOrder()
    • invoke

      public Object invoke(Invocation invocation) throws Throwable
      Description copied from interface: Expectation
      Invokes the expectation: records that the invocation has occurred and fakes some behaviour in response.
      Specified by:
      invoke in interface Expectation
      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.
    • performSideEffects

      private void performSideEffects()