@Test
public void Should_enqueueACallbackToResourceSource()
        throws Exception {

    AsynchronousOperationException asynchronousOperationException = mock(AsynchronousOperationException.class);
    when(messageProcessorMock.getSequence()).thenReturn(sequenceMock);
    when(contextMock.getValue(same(exceptionFieldName))).thenReturn(outOfResourceExceptionMock);
    when(contextMock.getValue(same(causeLevelFieldName))).thenReturn(135);
    when(contextMock.getValue(same(causeStepFieldName))).thenReturn(123);
    IMessageReceiver receiver = new RetryingToTakeResourceExceptionHandler();
    receiver.receive(messageProcessorMock);
    verify(sequenceMock).goTo(eq(135), eq(123));
    verify(resourceSourceMock).onAvailable(callbackCaptor.capture());
    callbackCaptor.getValue().execute();
    verify(messageProcessorMock).continueProcess(null);
    reset(messageProcessorMock);
    doThrow(asynchronousOperationException).when(messageProcessorMock).continueProcess(null);
    try {
        callbackCaptor.getValue().execute();
        fail();
    } catch (ActionExecuteException e) {
        assertSame(asynchronousOperationException, e.getCause());
    }
}