Class LatchCountDownAndCallRealMethodAnswer

  • All Implemented Interfaces:
    Serializable, org.mockito.stubbing.Answer<Object>

    public class LatchCountDownAndCallRealMethodAnswer
    extends org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
    An Answer for void returning methods that calls the real method and counts down a latch. Captures any exceptions thrown.
    Since:
    1.6
    Author:
    Gary Russell
    See Also:
    Serialized Form
    • Constructor Detail

      • LatchCountDownAndCallRealMethodAnswer

        public LatchCountDownAndCallRealMethodAnswer​(int count,
                                                     @Nullable
                                                     Object delegate)
        Get an instance with the provided properties. Use the test harness to get an instance with the proper delegate.
        Parameters:
        count - the count.
        delegate - the delegate.
        Since:
        2.1.16
    • Method Detail

      • answer

        public Object answer​(org.mockito.invocation.InvocationOnMock invocation)
                      throws Throwable
        Specified by:
        answer in interface org.mockito.stubbing.Answer<Object>
        Overrides:
        answer in class org.mockito.internal.stubbing.defaultanswers.ForwardsInvocations
        Throws:
        Throwable
      • await

        public boolean await​(int timeout)
                      throws InterruptedException
        Wait for the latch to count down.
        Parameters:
        timeout - the timeout in seconds.
        Returns:
        the result of awaiting on the latch; true if counted down.
        Throws:
        InterruptedException - if the thread is interrupted.
        Since:
        2.1.16
      • getExceptions

        @Nullable
        public Collection<Exception> getExceptions()
        Return the exceptions thrown.
        Returns:
        the exceptions.
        Since:
        2.2.3