Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Junit 如何使用带有参数的行映射器模拟jdbctemplate,仅使用mockito_Junit_Mockito - Fatal编程技术网

Junit 如何使用带有参数的行映射器模拟jdbctemplate,仅使用mockito

Junit 如何使用带有参数的行映射器模拟jdbctemplate,仅使用mockito,junit,mockito,Junit,Mockito,嗨,我需要帮助模仿下面的陈述 List<String> testString= jdbcTemplate.query(queryString, new Object[] { someStringParameter }, new testMapper()); List testString=jdbcTemplate.query(queryString,新对象[]{someStringParameter},新testMapper()); 使用下面的模拟工具实现了此功能 when(jdb

嗨,我需要帮助模仿下面的陈述

List<String> testString= jdbcTemplate.query(queryString, new Object[] { someStringParameter }, new testMapper());
List testString=jdbcTemplate.query(queryString,新对象[]{someStringParameter},新testMapper());

使用下面的模拟工具实现了此功能
when(jdbcTemplateMock.query)(anyString(),Matchers.anyVararg(),

Matchers.any(testMapper.class))
Mock
JdbcTemplate
方法
查询(字符串,对象[],行映射器)
使用行映射器和参数匹配器:

List<Model> list = new ArrayList<>();
list.add(someModel);

when(this.jdbcTemplate.query(anyString(), ArgumentMatchers.<Object[]>any(),
                ArgumentMatchers.<RowMapper<Model>>any())).thenReturn(list);
List List=new ArrayList();
添加(someModel);
当(this.jdbcTemplate.query)(anyString(),ArgumentMatchers.any()),
ArgumentMatchers.any())。然后返回(列表);