@Test(timeout = 1000L)
public void Should_letStrategyAccessManagedTask()
        throws Exception {

    ITask taskMock = mock(ITask.class);
    when(queueMock.tryTake())
            .thenReturn(taskMock)
            .thenReturn(null);
    ExecutionTaskWithStrategy executionTask = new ExecutionTaskWithStrategy(dispatcherMock, processStrategyMock);
    when(dispatcherMock.getExecutionTask()).thenReturn(executionTask);
    doAnswer(invocation -> {
        try {
            invocation.getArgumentAt(0, ITaskExecutionState.class).getTaskAs(IManagedTask.class);
            fail();
        } catch (InvalidArgumentException ignore) {}
        return null;
    }).when(processStrategyMock).process(any());
    executionTask.execute();
    IManagedTask managedTaskMock = mock(IManagedTask.class),
            managedTaskMock1 = mock(IManagedTask.class);
    when(managedTaskMock.getAs(IManagedTask.class)).thenReturn(managedTaskMock1);
    when(queueMock.tryTake())
            .thenReturn(managedTaskMock)
            .thenReturn(null);
    doAnswer(invocation -> {
        IManagedTask mt = invocation.getArgumentAt(0, ITaskExecutionState.class).getTaskAs(IManagedTask.class);
        assertSame(managedTaskMock1, mt);
        return null;
    }).when(processStrategyMock).process(any());
    executionTask.execute();
    verify(managedTaskMock).getAs(IManagedTask.class);
}