Reputation: 101
Hi i need help mocking the below statement.
List<String> testString= jdbcTemplate.query(queryString, new Object[] { someStringParameter }, new testMapper());
Upvotes: 5
Views: 14140
Reputation: 81
Mock JdbcTemplate
method query(String, Object[], RowMapper<T>)
using a RowMapper and ArgumentMatchers:
List<Model> list = new ArrayList<>();
list.add(someModel);
when(this.jdbcTemplate.query(anyString(), ArgumentMatchers.<Object[]>any(),
ArgumentMatchers.<RowMapper<Model>>any())).thenReturn(list);
Upvotes: 7
Reputation: 101
Got this working using the below mock
when(jdbcTemplateMock.query(anyString(), Matchers.<Object[]> anyVararg(),
Matchers.any(testMapper.class)))
Upvotes: 5