Invalid use of argument matchers

Mockito requires you to either use only raw values or only matchers when stubbing a method call. The full exception (not posted by you here) surely explains everything.

Simple change the line:

when(jdbcTemplate.queryForObject(anyString(), any(SqlParameterSource.class), String.class
                        )).thenReturn("Test");

to

when(jdbcTemplate.queryForObject(anyString(), any(SqlParameterSource.class), eq(String.class)
                        )).thenReturn("Test");

and it should work.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)