junit Mockito贴图类型

arknldoa  于 2022-11-11  发布在  其他
关注(0)|答案(1)|浏览(134)

这是我的准则:

@Test(expected = ThirdLevelException.class) public void buildChMarginStockTest3() throws Exception{

    when(clhCategoryHistoryDAO.countById(anyString() , any(Date.class), any(Date.class), anyInt()))
        .thenReturn(0L);
    doThrow(new RepositoryException()).when(genericDAO).executeStoredProcedure(anyString(), anyMap());

    updateMatViewNInfoTradesPaiNpvIccBean.elabThirdLevel(clhCategoryLoad, envelopeBean);

}

问题是 genericDAO.executeStoredProcedure() 需要两个参数:一个String和一个Map〈String,Object〉。现在的代码不好,因为有一个错误:* GenericDAO类型中的方法executeStoredProcedure(String,Map〈String,Object〉)不适用于参数(String,Map〈Object,Object〉)*。
我该如何解决这个问题?

wkftcu5l

wkftcu5l1#

经过一番研究后,我发现了如何做到这一点:而不是使用 anyMap 我必须使用 ArgumentMatchers.〈String,Object〉anyMap()

相关问题