単体テストを作成しようとしていますが、Integer.classのMockitoマッチャーを作成する方法がわかりません。
私は次の方法をテストしようとしています:
public List<Integer> getAllParticipatingChallengesByTeamId(int teamId) {
List<Integer> challengeIds = new ArrayList<Integer>();
MapSqlParameterSource args = new MapSqlParameterSource();
args.addValue("teamId", teamId);
try {
challengeIds = jdbcTemplate.queryForList(SQL_STRING, args, Integer.class);
} catch (Exception e) {
challengeIds = null;
}
return challengeIds;
}
次のようなマッチャーを使用して値を返すために、モックされたjdbcTemplateをスタブします。
when(mockJdbc.queryForList(anyString(), any(SqlParameterSource.class), any(Integer.class)).thenReturn(integerList);
しかしもちろん、これはクラスではなく、整数に一致します。Class.classなどを試してみましたが、オンラインや自分のやり方で理解できなかったようです。