我有ff。测试方法:
@Mock
private DBAccessor accessor;
/**
* Successful find().
*/
@Test
public void testFind() {
// Prepare
MockDto mockDto = mock(MockDto.class);
try {
when(accessor.executeQuery(any(Class.class), anyString(), any(ConcurrentHashMap.class))).thenReturn(
mockDto);
} catch (Exception e) {
fail("Unexpected exception.");
}
}
然而,ff。警告发生:
Multiple markers at this line
- Type safety: Unchecked invocation executeQuery(Class, String, ConcurrentHashMap) of the generic method executeQuery(Class<T>, String, Object) of type DBAccessor
- Type safety: The expression of type Class needs unchecked conversion to conform to Class<Object>
如何解决上述警告?
我使用Mockit和Powermock作为模拟框架和JUnit。