title: Mock with Mockito return a InvocationTargetException
body: <p>I'm writing some unit test and I stumble accross this strange "bug" which prevent me from running my unit test. </p>
  
  <p>When I run the "when(...).thenReturn(...)", I receive a InvocationTargetException. Then strange things is that when I debug, it goes into the real object and crash on a null member. When I debug other "when", it goes in a function called "Intercept" which prevent to go in the real code... I don't understand what is different with this object and how to prevent this weird behavior.</p>
  
  <p>Here is my unit test:</p>
  
  <pre><code>@Test
  public void getSyncStatusShouldReturnValueFromDiskWhenNotRunning() throws IOException {
      //Arrange
      when(updater.isDone()).thenReturn(true);
      when(brandSyncUpdater.isDone()).thenReturn(true); //This is where it throw error
      when(stationSyncUpdater.isDone()).thenReturn(true);
  
      //Act
      //Assert
  }
  </code></pre>
  
  <p>Here is my setUp() and member section of my unit class test</p>
  
  <pre><code>private Updater updater;
  private BrandSyncUpdater brandSyncUpdater;
  private StationSyncUpdater stationSyncUpdater;
  
  @Before
  public void setUp() {
      updater = mock(Updater.class);
      brandSyncUpdater = mock(BrandSyncUpdater.class);
      stationSyncUpdater = mock(StationSyncUpdater.class);
  }
  </code></pre>
  
  <p>I don't know if it's related but the BrandSyncUpdater and StationSyncUpdater both have a parent called SyncUpdater where the isDone() function is located.</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p><strong>Hierarchy of class</strong></p>
  
  <p><code>Updater</code> is a class on its own</p>
  
  <p><code>BrandSyncUpdater</code> and <code>StationSyncUpdater</code> are extending <code>SyncUpdater</code></p>
  
  <p><code>Updater isDone()</code> signature and code:</p>
  
  <pre><code>public boolean isDone() {
      return states.isEmpty();
  }
  </code></pre>
  
  <p><code>SyncUpdater isDone()</code> signature and code:</p>
  
  <pre><code>public boolean isDone() {
      return currentStates.isEmpty();
  }
  </code></pre>
  
  <p><strong><em>EDIT 2</em></strong></p>
  
  <p>Here is the stack traces of the error in the console. You'll notice that the error here is a "NullPointerException" because it try to use the variable <code>currentStates</code>. But when debugging, the error thrown by mockito is InvocationTargetException.</p>
  
  <pre><code>java.lang.NullPointerException
      at com.stingray360.clap.synchronizer.contentcontroller.queue.SyncUpdater.isDone(SyncUpdater.java:117)
      at com.stingray360.clap.synchronizer.contentcontroller.queue.BrandSyncUpdater.isDone(BrandSyncUpdater.java:15)
      at com.stingray360.clap.synchronizer.contentcontroller.SyncDispatcherTest.getSyncStatusShouldReturnValueFromDiskWhenNotRunning(SyncDispatcherTest.java:190)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
  </code></pre>