title: How to mock jdbcTemplate.query with parameters (Object[]{})
body: <p>I'm trying using mockito to mock jdbcTemplate and call the method query passing it parameters using Object[]{}.</p>
  
  <p>I'm making the unit test for my DAO layer I want to mock jdbcTemplate and call the method query and pass the sql string,a RowMapper and parameters using Object[] {}</p>
  
  <pre><code>public List&lt;EntityType&gt; myDaoMethod(Date fechaInicio, Date fechaFin)
              throws NotDataFoundException {
          log.info("entering =&gt; myDaoMethod");
          log.info("param =&gt; fechaInicio :" +  fechaInicio);
          log.info("param =&gt; fechaFin :" +  fechaFin);
  
          log.debug("Se ejecutando consulta...");
          try {
  
              List&lt;EntityType&gt; query = jdbcTemplate.query(QueryStrs.MY_QUERY,
                      new Object[] {fechaInicio, fechaFin},
                      new BeanPropertyRowMapper&lt;EntityType&gt;(EntityType.class));
              log.debug("Se ejecuto consulta. ");
  
              return query;
          }catch(DataAccessException e) {
              log.error("No se encontro informacion en la consulta myDaoMethod (2)", e);
              throw new NotDataFoundException(e);
          }finally {
              log.info("exiting =&gt; myDaoMethod");
          }
      }
  </code></pre>
  
  <pre><code>    @Mock
      private JdbcTemplate jdbcTemplate;
  
          @Test
      public void myTestMethod() throws NotDataFoundException {
  
          List&lt;EntityType&gt; listValue = new ArrayList&lt;&gt;();
  
          listValue.add(new EntityType((short) 2, "modem 2"));
          listValue.add(new EntityType((short) 1, "modem"));
  
          when(jdbcTemplate.query(any(String.class),any(Object[].class), any(BeanPropertyRowMapper.class))).thenReturn(listValue);
  
          MyDao dao = new MyDaoImpl(jdbcTemplate);
          List&lt;EntityType&gt; otrasAdicionalesPorRangoFecha = dao.myDaoMethod(any(Date.class), any(Date.class));
  
          Assert.assertNotNull(otrasAdicionalesPorRangoFecha);
          Assert.assertTrue(!otrasAdicionalesPorRangoFecha.isEmpty());
  //      Assert.assertArrayEquals(listValue.toArray(), otrasAdicionalesPorRangoFecha.toArray());
  
      }
  </code></pre>
  
  <p>The trace result is</p>
  
  <p>org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
  Invalid use of argument matchers!
  3 matchers expected, 2 recorded:
  -> at com.oracle.reporter.tddtest.rrhhcomision.OtrasAdicionalesDaoTest.testBuscarOtrasAdicionalesPorFecha(OtrasAdicionalesDaoTest.java:80)
  -> at com.oracle.reporter.tddtest.rrhhcomision.OtrasAdicionalesDaoTest.testBuscarOtrasAdicionalesPorFecha(OtrasAdicionalesDaoTest.java:80)</p>
  
  <p>This exception may occur if matchers are combined with raw values:
      //incorrect:
      someMethod(anyObject(), "raw String");
  When using matchers, all arguments have to be provided by matchers.
  For example:
      //correct:
      someMethod(anyObject(), eq("String by matcher"));</p>