title: Mockito UnfinishedStubbingException with when().thenReturn()
body: <p>I am getting the error message <code>Unfinished Stubbing detected here</code>, when running the following code:</p>
  
  <pre><code>import static org.mockito.Mockito.mock;
  import static org.mockito.Mockito.*;
  import org.mockito.Mock;
  import org.powermock.api.mockito.PowerMockito;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.modules.junit4.PowerMockRunner;
  import org.powermock.reflect.Whitebox;
  
  @RunWith(PowerMockRunner.class)
  public class PatchWriterTaskTest {
  @Before
  public void before() throws Exception {
      filePath = getFilePath();
      task = PowerMockito.spy(new PatchWriterTask());
      patchFilesName = new HashMap&lt;Integer, String&gt;();
  
      patchFilesName.put(1, "TCE_RDF_COVERED_DATA_REGION.sql");
  
      scriptPath = new File(filePath + "do_patch_rdf.sql");
  
      PowerMockito.when(task, "getLogger").thenReturn(logger);
      PowerMockito.when(task, "getPatchFilesName").thenReturn(patchFilesName);
      PowerMockito.when(task, "getDirectoryPath").thenReturn(filePath);
      PowerMockito.when(task, "saveDoPatchFile");
  }
  @Test
  public void testUpdateIssuesTable() throws Exception {
          PatchWriterTask task = new PatchWriterTask();
          Connection conn = mock(Connection.class);
          PreparedStatement updateStatement = mock(PreparedStatement.class);
          String sql = "update val_issues set PATCH_CREATION_INFO = ? where VAL_ISSUE_ID = ?";
          when(conn.prepareStatement(sql)).thenReturn(updateStatement);
  </code></pre>
  
  <p>The last line throws the error. It doesn't really make sense, as I have done the same code before. Why am I getting this error?</p>
  
  <p>EDIT: I am using powerMockito in order to use the <code>Whitebox.invokeMethod()</code> method, but I also want to use regular Mockito in the rest of the program. Could that be a problem?</p>
  
  <p>Stack Trace:</p>
  
  <pre class="lang-none prettyprint-override"><code>org.mockito.exceptions.misusing.UnfinishedStubbingException: 
  Unfinished stubbing detected here:
  -&gt; at org.powermock.api.mockito.PowerMockito.when(PowerMockito.java:426)
  
  E.g. thenReturn() may be missing.
  Examples of correct stubbing:
      when(mock.isOk()).thenReturn(true);
      when(mock.isOk()).thenThrow(exception);
      doThrow(exception).when(mock).someVoidMethod();
  Hints:
   1. missing thenReturn()
   2. you are trying to stub a final method, you naughty developer!
  
      at com.navteq.rdf.base.task.PatchWriterTaskTest.testUpdateIssuesTable(PatchWriterTaskTest.java:78)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
      at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
      at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
      at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
      at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
      at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
      at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:118)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:104)
      at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
      at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>