title: How to mock Spring's JdbcTemplate.queryForList using Mockito?
body: <p>I want to know how to mock the particular code using Mockito:</p>
  
  <pre><code>List&lt;Map&lt;String, Object&gt;&gt; list = jdbcTemplate.queryForList(
      sqlQuery, 
      new Object[] { inflowId }
  );
  </code></pre>
  
  <p>I tried the following code:</p>
  
  <pre><code>Mockito.doReturn(list)
         .when(jdbcTemplate)
         .queryForList(Mockito.anyString(), Mockito.any(Class.class));
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>when(
      jdbcTemplate.queryForList(Mockito.anyString(), Mockito.any(Object[].class))
  ).thenReturn(list);
  </code></pre>
  
  <p>My problem is that particular method is not getting mocked in JUnit. When the method is called, it returns <code>null</code> whereas it should return the list.</p>