4646import org .junit .BeforeClass ;
4747import org .junit .Test ;
4848import org .mockito .Mockito ;
49- import org .mockito .MockitoAnnotations ;
5049import org .mockito .invocation .InvocationOnMock ;
5150import org .mockito .stubbing .Answer ;
5251import org .slf4j .event .Level ;
5958import static org .junit .Assert .assertNull ;
6059import static org .junit .Assert .assertTrue ;
6160import static org .junit .Assert .fail ;
62- import static org .mockito .Matchers .any ;
63- import static org .mockito .Matchers .anyLong ;
61+ import static org .mockito .ArgumentMatchers .any ;
62+ import static org .mockito .ArgumentMatchers .anyLong ;
6463import static org .mockito .Mockito .mock ;
6564import static org .mockito .Mockito .verifyNoMoreInteractions ;
6665import static org .mockito .Mockito .when ;
@@ -367,8 +366,10 @@ public void testGetHAServiceStateWithTimeout() throws Exception {
367366
368367 setupProxyProvider (1 , NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT );
369368 final HAServiceState state = HAServiceState .STANDBY ;
369+ @ SuppressWarnings ("unchecked" )
370370 NNProxyInfo <ClientProtocol > dummyNNProxyInfo =
371371 (NNProxyInfo <ClientProtocol >) mock (NNProxyInfo .class );
372+ @ SuppressWarnings ("unchecked" )
372373 Future <HAServiceState > task = mock (Future .class );
373374 when (task .get (anyLong (), any (TimeUnit .class ))).thenReturn (state );
374375
@@ -389,8 +390,10 @@ public void testTimeoutExceptionGetHAServiceStateWithTimeout() throws Exception
389390 proxyLog .clearOutput ();
390391
391392 setupProxyProvider (1 , NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT );
393+ @ SuppressWarnings ("unchecked" )
392394 NNProxyInfo <ClientProtocol > dummyNNProxyInfo =
393395 (NNProxyInfo <ClientProtocol >) Mockito .mock (NNProxyInfo .class );
396+ @ SuppressWarnings ("unchecked" )
394397 Future <HAServiceState > task = mock (Future .class );
395398 TimeoutException e = new TimeoutException ("Timeout" );
396399 when (task .get (anyLong (), any (TimeUnit .class ))).thenThrow (e );
@@ -413,8 +416,10 @@ public void testInterruptedExceptionGetHAServiceStateWithTimeout() throws Except
413416 proxyLog .clearOutput ();
414417
415418 setupProxyProvider (1 , NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT );
419+ @ SuppressWarnings ("unchecked" )
416420 NNProxyInfo <ClientProtocol > dummyNNProxyInfo =
417421 (NNProxyInfo <ClientProtocol >) Mockito .mock (NNProxyInfo .class );
422+ @ SuppressWarnings ("unchecked" )
418423 Future <HAServiceState > task = mock (Future .class );
419424 InterruptedException e = new InterruptedException ("Interrupted" );
420425 when (task .get (anyLong (), any (TimeUnit .class ))).thenThrow (e );
@@ -436,8 +441,10 @@ public void testExecutionExceptionGetHAServiceStateWithTimeout() throws Exceptio
436441 proxyLog .clearOutput ();
437442
438443 setupProxyProvider (1 , NAMENODE_HA_STATE_PROBE_TIMEOUT_SHORT );
444+ @ SuppressWarnings ("unchecked" )
439445 NNProxyInfo <ClientProtocol > dummyNNProxyInfo =
440446 (NNProxyInfo <ClientProtocol >) Mockito .mock (NNProxyInfo .class );
447+ @ SuppressWarnings ("unchecked" )
441448 Future <HAServiceState > task = mock (Future .class );
442449 Exception e = new ExecutionException (new InterruptedException ("Interrupted" ));
443450 when (task .get (anyLong (), any (TimeUnit .class ))).thenThrow (e );
@@ -452,16 +459,18 @@ public void testExecutionExceptionGetHAServiceStateWithTimeout() throws Exceptio
452459 }
453460
454461 /**
455- * Test GetHAServiceState when timeout is disabled (test the else { task.get() } code path)
462+ * Test GetHAServiceState when timeout is disabled (test the else { task.get() } code path).
456463 */
457464 @ Test
458465 public void testGetHAServiceStateWithoutTimeout () throws Exception {
459466 proxyLog .clearOutput ();
460467 setupProxyProvider (1 , 0 );
461468
462469 final HAServiceState state = HAServiceState .STANDBY ;
470+ @ SuppressWarnings ("unchecked" )
463471 NNProxyInfo <ClientProtocol > dummyNNProxyInfo =
464472 (NNProxyInfo <ClientProtocol >) mock (NNProxyInfo .class );
473+ @ SuppressWarnings ("unchecked" )
465474 Future <HAServiceState > task = mock (Future .class );
466475 when (task .get ()).thenReturn (state );
467476
0 commit comments