title: Mockito: spy a spring autowrite bean, it's not work
body: <p>I want mock approveActivity method at the spy a spring bean.</p>
  
  <p>but on this, it's not work.</p>
  
  <ol>
  <li><p>spring auto write object is success.</p></li>
  <li><p>spy object is success.</p></li>
  <li><p>mock method throw exception.</p></li>
  </ol>
  
  <p>enter code here</p>
  
  <p>I don't know why, Please help me!</p>
  
  <p>SpringFramework 3.X and Mockito 2.x and Junit 4.X.</p>
  
  <pre><code>public class ActivityBasicSmokeTest extends AbstractSmockMockito4SpringTest {
  
  
      @Autowired
      private ActivityReduceAPI activityReduceAPI;
  
      @Test
      public void testForApprovingActivityStatus() throws FileNotFoundException {
  
          ActivityReduceAPI spyActivityReduceAPI = Mockito.spy(this.activityReduceAPI);
  
          // stop auto audit
          Mockito.doReturn(new ResultGeneralModel&lt;&gt;(true)).when(spyActivityReduceAPI)
              .approveActivity("1", 2L);  &lt;---- this is throw Exception.
  
      }
  
  }
  </code></pre>
  
  <p>ActivityReduceAPIImpl.java</p>
  
  <pre><code>@Override
  public ResultGeneralModel&lt;Boolean&gt; approveActivity(String token, Long id) {
      try {
          AccountResponse account = sessionContext.getAccountFromTairByToken(token);
          ReduceActivityEntity activityEntity = activityService.get(id, account);
          ActivityParamUtil.validBeforeModified(activityEntity, ActivityStatusEnum.CREATE);
          Errors error = activityService.approveReduce(activityEntity, account);
          if (null != error) {
              return new ResultGeneralModel&lt;&gt;(error);
          }
          return new ResultGeneralModel&lt;&gt;(true);
      } catch (TfavatarBusException e) {
          return new ResultGeneralModel(ErrorUtil.getErrors(e));
      }
  }
  </code></pre>
  
  <hr>
  
  <p>org.mockito.exceptions.misusing.UnfinishedStubbingException: 
  Unfinished stubbing detected here:
      at com.taobao.film.tfavatar.domain.reduce.ActivityBasicSmokeTest.testForApprovingActivityStatus(ActivityBasicSmokeTest.java:458)</p>
  
  <hr>
  
  <p>E.g. thenReturn() may be missing.
  Examples of correct stubbing:</p>
  
  <pre><code>when(mock.isOk()).thenReturn(true);
  when(mock.isOk()).thenThrow(exception);
  doThrow(exception).when(mock).someVoidMethod();
  </code></pre>
  
  <p>Hints:
   1. missing thenReturn()
   2. you are trying to stub a final method, which is not supported
   3: you are stubbing the behaviour of another mock inside before 'thenReturn' instruction is completed</p>
  
  <pre><code>at com.taobao.film.tfavatar.api.impl.ActivityReduceAPIImpl.approveActivity(ActivityReduceAPIImpl.java:192)
  at com.taobao.film.tfavatar.api.impl.ActivityReduceAPIImpl$$FastClassBySpringCGLIB$$f237c997.invoke(&lt;generated&gt;)
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
  at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:93)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)
  at com.taobao.film.tfavatar.api.impl.ActivityReduceAPIImpl$$EnhancerBySpringCGLIB$$4b39213a.approveActivity(&lt;generated&gt;)
  at com.taobao.film.tfavatar.domain.reduce.ActivityBasicSmokeTest.testForApprovingActivityStatus(ActivityBasicSmokeTest.java:459)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
  at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
  at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
  at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
  at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  </code></pre>