22
33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertNotNull ;
5- import static org .junit .Assert .assertTrue ;
65import static org .junit .Assert .fail ;
7- import static org .mockito .ArgumentMatchers .any ;
8- import static org .mockito .ArgumentMatchers .anyLong ;
9- import static org .mockito .Mockito .doAnswer ;
106import static org .mockito .Mockito .inOrder ;
117import static org .mockito .Mockito .mock ;
128import static org .mockito .Mockito .times ;
1511import java .time .Duration ;
1612import java .util .concurrent .atomic .AtomicLong ;
1713import java .util .function .LongConsumer ;
14+ import org .hamcrest .MatcherAssert ;
15+ import org .hamcrest .Matchers ;
1816import org .junit .Test ;
17+ import org .mockito .ArgumentMatchers ;
1918import org .mockito .InOrder ;
19+ import org .mockito .Mockito ;
2020import org .mockito .invocation .InvocationOnMock ;
2121import org .mockito .stubbing .Answer ;
2222
@@ -99,7 +99,7 @@ protected void sleep(long sleepMillis) {
9999 }
100100 InOrder inOrder = inOrder (connectionHandler , sleep );
101101 inOrder .verify (connectionHandler , times (2 )).getConnection (STR_COM_OBJECT .getArguments ());
102- inOrder .verify (sleep ).accept (anyLong ());
102+ inOrder .verify (sleep ).accept (ArgumentMatchers . anyLong ());
103103 inOrder .verify (connectionHandler ).renewSlotCache ();
104104 inOrder .verify (connectionHandler ).getConnection (STR_COM_OBJECT .getArguments ());
105105 inOrder .verifyNoMoreInteractions ();
@@ -134,7 +134,7 @@ protected void sleep(long ignored) {
134134
135135 InOrder inOrder = inOrder (connectionHandler );
136136 inOrder .verify (connectionHandler ).getConnection (STR_COM_OBJECT .getArguments ());
137- inOrder .verify (connectionHandler ).renewSlotCache (any ());
137+ inOrder .verify (connectionHandler ).renewSlotCache (ArgumentMatchers . any ());
138138 inOrder .verify (connectionHandler ).getConnection (movedTarget );
139139 inOrder .verifyNoMoreInteractions ();
140140 }
@@ -191,8 +191,8 @@ public void runMovedThenAllNodesFailing() {
191191 when (connectionHandler .getConnection (STR_COM_OBJECT .getArguments ())).thenReturn (redirecter );
192192
193193 final Connection failer = mock (Connection .class );
194- when (connectionHandler .getConnection (any (HostAndPort .class ))).thenReturn (failer );
195- doAnswer ((Answer ) (InvocationOnMock invocation ) -> {
194+ when (connectionHandler .getConnection (ArgumentMatchers . any (HostAndPort .class ))).thenReturn (failer );
195+ Mockito . doAnswer ((Answer ) (InvocationOnMock invocation ) -> {
196196 when (connectionHandler .getConnection (STR_COM_OBJECT .getArguments ())).thenReturn (failer );
197197 return null ;
198198 }).when (connectionHandler ).renewSlotCache ();
@@ -231,10 +231,10 @@ protected void sleep(long sleepMillis) {
231231 inOrder .verify (connectionHandler ).getConnection (STR_COM_OBJECT .getArguments ());
232232 inOrder .verify (connectionHandler ).renewSlotCache (redirecter );
233233 inOrder .verify (connectionHandler , times (2 )).getConnection (movedTarget );
234- inOrder .verify (sleep ).accept (anyLong ());
234+ inOrder .verify (sleep ).accept (ArgumentMatchers . anyLong ());
235235 inOrder .verify (connectionHandler ).renewSlotCache ();
236236 inOrder .verify (connectionHandler , times (2 )).getConnection (STR_COM_OBJECT .getArguments ());
237- inOrder .verify (sleep ).accept (anyLong ());
237+ inOrder .verify (sleep ).accept (ArgumentMatchers . anyLong ());
238238 inOrder .verify (connectionHandler ).renewSlotCache ();
239239 inOrder .verifyNoMoreInteractions ();
240240 }
@@ -260,13 +260,13 @@ public void runMasterFailingReplicaRecovering() {
260260
261261 when (connectionHandler .getConnection (STR_COM_OBJECT .getArguments ())).thenReturn (master );
262262
263- doAnswer ((Answer ) (InvocationOnMock invocation ) -> {
263+ Mockito . doAnswer ((Answer ) (InvocationOnMock invocation ) -> {
264264 when (connectionHandler .getConnection (STR_COM_OBJECT .getArguments ())).thenReturn (replica );
265265 return null ;
266266 }).when (connectionHandler ).renewSlotCache ();
267267
268268 final AtomicLong totalSleepMs = new AtomicLong ();
269- ClusterCommandExecutor testMe = new ClusterCommandExecutor (connectionHandler , 10 , ONE_SECOND ) {
269+ ClusterCommandExecutor testMe = new ClusterCommandExecutor (connectionHandler , 5 , ONE_SECOND ) {
270270
271271 @ Override
272272 public <T > T execute (Connection connection , CommandObject <T > commandObject ) {
@@ -294,7 +294,7 @@ protected void sleep(long sleepMillis) {
294294 inOrder .verify (connectionHandler ).renewSlotCache ();
295295 inOrder .verify (connectionHandler ).getConnection (STR_COM_OBJECT .getArguments ());
296296 inOrder .verifyNoMoreInteractions ();
297- assertTrue (totalSleepMs .get () > 0 );
297+ MatcherAssert . assertThat (totalSleepMs .get (), Matchers . greaterThan ( 0L ) );
298298 }
299299
300300 @ Test (expected = JedisClusterOperationException .class )
0 commit comments