InOrderImpl
Date: 2015-09-18

org.mockito.internal

## Class InOrderImpl

- java.lang.Object
- - org.mockito.internal.InOrderImpl

- All Implemented Interfaces:
    InOrder, InOrderContext

      public class InOrderImpl
      extends java.lang.Object
      implements InOrder, InOrderContext

  Allows verifying in order. This class should not be exposed, hence default access.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InOrderImpl(java.util.List<java.lang.Object> mocksToBeVerifiedInOrder)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.List<java.lang.Object>` | `getMocksToBeVerifiedInOrder()`
    `boolean` | `isVerified(Invocation i)`
    `void` | `markVerified(Invocation i)`
    `<T> T` | `verify(T mock)` Verifies interaction happened once in order.
    `<T> T` | `verify(T mock, VerificationMode mode)` Verifies interaction in order.
    `void` | `verifyNoMoreInteractions()` Verifies that no more interactions happened in order.

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

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

- - ### Constructor Detail

    - #### InOrderImpl

          public InOrderImpl(java.util.List<java.lang.Object> mocksToBeVerifiedInOrder)

  - ### Method Detail

    - #### getMocksToBeVerifiedInOrder

          public java.util.List<java.lang.Object> getMocksToBeVerifiedInOrder()

    - #### verify

          public <T> T verify(T mock)

      Description copied from interface: `InOrder`
      Verifies interaction happened once in order.

      Alias to `inOrder.verify(mock, times(1))`

      Example:

           InOrder inOrder = inOrder(firstMock, secondMock);

           inOrder.verify(firstMock).someMethod("was called first");
           inOrder.verify(secondMock).someMethod("was called second");

      See examples in javadoc for `Mockito` class
      Specified by:
        `verify` in interface `InOrder`
      Parameters:
        `mock` - to be verified
      Returns:
        mock object itself

    - #### verify

          public <T> T verify(T mock,
                     VerificationMode mode)

      Description copied from interface: `InOrder`
      Verifies interaction in order. E.g:

           InOrder inOrder = inOrder(firstMock, secondMock);

           inOrder.verify(firstMock, times(2)).someMethod("was called first two times");
           inOrder.verify(secondMock, atLeastOnce()).someMethod("was called second at least once");

      See examples in javadoc for `Mockito` class
      Specified by:
        `verify` in interface `InOrder`
      Parameters:
        `mock` - to be verified
        `mode` - for example times(x) or atLeastOnce()
      Returns:
        mock object itself

    - #### isVerified

          public boolean isVerified(Invocation i)

      Specified by:
        `isVerified` in interface `InOrderContext`

    - #### markVerified

          public void markVerified(Invocation i)

      Specified by:
        `markVerified` in interface `InOrderContext`

    - #### verifyNoMoreInteractions

          public void verifyNoMoreInteractions()

      Description copied from interface: `InOrder`
      Verifies that no more interactions happened in order. Different from `Mockito.verifyNoMoreInteractions(Object...)` because the order of verification matters.

      Example:

           mock.foo(); //1st
           mock.bar(); //2nd
           mock.baz(); //3rd

           InOrder inOrder = inOrder(mock);

           inOrder.verify(mock).bar(); //2n
           inOrder.verify(mock).baz(); //3rd (last method)

           //passes because there are no more interactions after last method:
           inOrder.verifyNoMoreInteractions();

           //however this fails because 1st method was not verified:
           Mockito.verifyNoMoreInteractions(mock);

      Specified by:
        `verifyNoMoreInteractions` in interface `InOrder`