Daniele Scalco
Daniele Scalco

Reputation: 191

Mockito Map type

That's my code:

@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);
        
}

The problem is that genericDAO.executeStoredProcedure() needs two parameters: a String and a Map<String, Object>. The code as it is now is not good cause has an error: The method executeStoredProcedure(String, Map<String,Object>) in the type GenericDAO is not applicable for the arguments (String, Map<Object,Object>).

How can I solve this?

Upvotes: 0

Views: 780

Answers (1)

Daniele Scalco
Daniele Scalco

Reputation: 191

After a bit of research I founded how to do that: instead of using anyMap I have to use ArgumentMatchers.<String, Object>anyMap()

Upvotes: 2

Related Questions