title: Mockito when method not working
body: <p>I am using mockito as mocking framework. I have a scenerio here, my when(abc.method()).thenReturn(value) does not return value, instead it returns null.</p>
  
  <pre><code>public class DQExecWorkflowServiceImplTest {
  @InjectMocks
  DQExecWorkflowServiceImpl dqExecWorkflowServiceImpl = new DQExecWorkflowServiceImpl();
  @Mock
  private DQUtility dqUtility;
  @Mock
  private DqExec dqExec;
  @Mock
  private DqCntlDefn dqCntlDefn;
  @Mock
  private DqCntlWfDefn dqCntlWfDefn;
  @Mock
  private DqCntlWfDefnTyp dqCntlWfDefnTyp;
  @Mock
  private IDQControlWfDefTypeService controlWfDefTypeService;
  
  @Before
  public void setUp() throws Exception {
      dqExec = new DqExec();
      dqCntlWfDefn = new DqCntlWfDefn();
      dqUtility = new DQUtility();
      dqCntlWfDefnTyp = new DqCntlWfDefnTyp();
      dqCntlWfDefnTyp.setDqCntlWfDefnTypCd("MIN_INCLUSIVE_VAL");
      dqExecWorkflowServiceImpl
              .setControlWfDefTypeService(controlWfDefTypeService);
  
  }
  
  @Test
  public void testExecuteWorkflow() {
      when(controlWfDefTypeService.getDqCntlWfDefnTypCd(dqCntlWfDefn))
              .thenReturn(dqCntlWfDefnTyp);
      dqExecWorkflowServiceImpl.executeWorkflow(dqExec, dqCntlWfDefn);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><b>Java class</b></p>
  
  <pre><code>@Override
  public DqCntlWfExec executeWorkflow(final DqExec dqExec,
          final DqCntlWfDefn dqCntlWfDefn) {
  final DqCntlWfExec dqCntlWfExec = new DqCntlWfExec();
  dqCntlWfExec.setDqCntlWfExecEffDt(dqUtil.getDefaultEffectiveDt());
  dqCntlWfExec.setDqCntlWfExecExpDt(dqUtil.getDefaultExpiryDt());
  dqCntlWfExec.setDqCntlWfDefn(dqCntlWfDefn);
  dqCntlWfExec.setDqExec(dqExec);
  
  final DqCntlWfDefnTyp dqCntlWfDefnTyp = controlWfDefTypeService
      .getDqCntlWfDefnTypCd(dqCntlWfDefn);
       String workflowType = null;
  if(null!=dqCntlWfDefnTyp){
      workflowType = dqCntlWfDefnTyp.getDqCntlWfDefnTypCd();
  }
  </code></pre>
  
  <p>When ever i run the test file the when is not working and i am using mockito1.8.5 jar in the buildpath. The service call is being mocked but returns the null value.</p>
  
  <pre><code>final DqCntlWfDefnTyp dqCntlWfDefnTyp = controlWfDefTypeService
      .getDqCntlWfDefnTypCd(dqCntlWfDefn);
  </code></pre>
  
  <p>This object dqCntlWfDefnTyp is null</p>
  
  <p>I have done this before and there was no problem with the when, It seems to be working with files i have done before. I had followed the same procedure for the test file but i couldnt figure out the issue. Can anyone please assist me</p>
  
  <p>Thanks to all the folks in advance</p>