title: mockito test invocation into abstract executor
body: <p>I am writing test on a legacy code, before refactoring it, this means that <strong>I should not change that code</strong>...
  I am using Spring and Hazelcast, and my class is an Hazelcast Listener (if you don't know Hazelcast it does not matter, just be aware that I cannot change the firm of the method). </p>
  
  <pre><code>@Component
  public class MyClass implements EntryAddedListener&lt;String, MyEntry&gt; {
  
      @Autowired
      @Qualifier( "asyncExecutor" )
      private Executor executor;
  
      @Autowired
      private ClassToBeCalled classToBeCalled;
  
      @Override
      public void entryAdded( final EntryEvent&lt;String, MyEntry&gt; event ) {
          executor.execute( () -&gt; {
                  ...
                  ...
                  classToBeCalled.methodToBeCalled( event.getValue() );
              }
          } );
      }
  }
  </code></pre>
  
  <p>I want to test that when <code>entryAdded</code> is called, then <code>execute</code> is invoked, and especially <code>methodToBeCalled</code> is invoked as well.
  I am trying different approaches, but all of them are bumping into some mockito error. This is the last one:</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class MyClass {
  
      @Mock
      private Executor asyncExecutor;
  
      @Mock
      private ClassToBeCalled classToBeCalled;
  
      @InjectMocks
      private MyClass myClass;
  
      @Test
      public void entryListenerShouldInvokeTheClassToBeCalled(){
          // given
          EntryEvent entryEvent = mock(EntryEvent.class);
          MyEntry value = mock(MyEntry.class);
          when(entryEvent.getValue()).thenReturn(value);
  
          // here some of my tries, all commented because they don't work
          // doCallRealMethod().when(asyncExecutor).execute(any(Runnable.class));
          // when(executor.execute(any(Runnable.class))).thenCallRealMethod();
  
          // when
          myClass.entryAdded(entryEvent);
  
          // then
          verify(asyncExecutor, times(1)).execute(any(Runnable.class));
          verify(classToBeCalled, times(1)).methodToBeCalled(value);
      }
  }
  </code></pre>
  
  <p>basically I cannot verify that the <code>methodToBeCalled</code> is called, because Executor is an abstract class. I cannot Spy it, I cannot call the real method. Also, the @Qualifier refers to an implementation in a library, which more or less is:</p>
  
  <pre><code>    @Bean(name = {"AsyncExecutor"})
      public Executor getAsyncExecutor() {
          ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
          ...
          ...
          executor.initialize();
          return executor;
      }
  </code></pre>
  
  <p>Any idea?</p>