AbstractExpectation
Date: 2015-09-15

org.jmock.expectation

## Class AbstractExpectation

- java.lang.Object
- - org.jmock.expectation.AbstractExpectation

- All Implemented Interfaces:
    Verifiable, Expectation
  Direct Known Subclasses:
    AbstractExpectationCollection, ExpectationCounter, ExpectationDoubleValue, ExpectationSegment, ExpectationValue

      public abstract class AbstractExpectation
      extends java.lang.Object
      implements Verifiable, Expectation

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `myFailureModeIsImmediate`
    `protected java.lang.String` | `myName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractExpectation(java.lang.String name)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `assertEquals(java.lang.String msg, int expectedValue, int actualValue)`
    `protected void` | `assertEquals(java.lang.String msg, java.lang.Object expectedValue, java.lang.Object actualValue)` Due to junit Assert being a Singleton implemented with static methods, and java's unfortunate implementation of class methods (e.g.
    `abstract void` | `clearActual()`
    `boolean` | `hasExpectations()` Return true if any expectations have been set on this object.
    `void` | `setFailOnVerify()` If an incorrect actual value is set, defer reporting this as a failure until verify() is called on this object.
    `protected void` | `setHasExpectations()`
    `protected boolean` | `shouldCheckImmediately()`
    `abstract void` | `verify()` Throw an AssertionFailedException if any expectations have not been met.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.jmock.expectation.Expectation

      `setExpectNothing`

- - ### Field Detail

    - #### myFailureModeIsImmediate

          protected boolean myFailureModeIsImmediate

    - #### myName

          protected java.lang.String myName

  - ### Constructor Detail

    - #### AbstractExpectation

          public AbstractExpectation(java.lang.String name)

  - ### Method Detail

    - #### assertEquals

          protected void assertEquals(java.lang.String msg,
                          int expectedValue,
                          int actualValue)

    - #### assertEquals

          protected void assertEquals(java.lang.String msg,
                          java.lang.Object expectedValue,
                          java.lang.Object actualValue)

      Due to junit Assert being a Singleton implemented with static methods, and java's unfortunate implementation of class methods (e.g. no late binding) it is necessary to re-implement this invokedMethod here instead of over-riding failNotEquals

    - #### clearActual

          public abstract void clearActual()

    - #### hasExpectations

          public boolean hasExpectations()

      Description copied from interface: `Expectation`
      Return true if any expectations have been set on this object.
      Specified by:
        `hasExpectations` in interface `Expectation`

    - #### setFailOnVerify

          public void setFailOnVerify()

      Description copied from interface: `Expectation`
      If an incorrect actual value is set, defer reporting this as a failure until verify() is called on this object.
      Specified by:
        `setFailOnVerify` in interface `Expectation`

    - #### setHasExpectations

          protected void setHasExpectations()

    - #### shouldCheckImmediately

          protected boolean shouldCheckImmediately()

    - #### verify

          public abstract void verify()

      Description copied from interface: `Verifiable`
      Throw an AssertionFailedException if any expectations have not been met. Implementations of this method must be idempotent: jMock can call this method more than once when verifying expectations at the end of a test.
      Specified by:
        `verify` in interface `Verifiable`