2

I have the ff. test method:

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

However, the ff. warning occcurs:

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>

How do I resolve the above warnings?

I'm using Mockit and Powermock as mocking frameworks and JUnit.

Tristan Warner-Smith
  • 9,631
  • 6
  • 46
  • 75
Jonathan
  • 2,244
  • 1
  • 23
  • 29

1 Answers1

0

As indicated in the ff. post, it can be removed by @SuppressWarnings("unchecked").

Community
  • 1
  • 1
Jonathan
  • 2,244
  • 1
  • 23
  • 29