Eliminate use of deprecated mockito methods
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / RaftActorTest.java
index f9c88f7fd3d2868cc22f38b24180c274204a6125..2c975ecf08e1d5aecdd13685f0be90ad4b3eed7e 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
@@ -14,10 +13,9 @@ import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.same;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.same;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -43,6 +41,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectOutputStream;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -91,7 +90,6 @@ import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.opendaylight.yangtools.concepts.Identifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class RaftActorTest extends AbstractActorTest {
@@ -183,7 +181,7 @@ public class RaftActorTest extends AbstractActorTest {
 
         // kill the actor
         followerActor.tell(PoisonPill.getInstance(), null);
-        kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
 
         kit.unwatch(followerActor);
 
@@ -414,7 +412,7 @@ public class RaftActorTest extends AbstractActorTest {
         final Identifier id = new MockIdentifier("apply-state");
         mockRaftActor.getRaftActorContext().getApplyStateConsumer().accept(new ApplyState(mockActorRef, id, entry));
 
-        verify(mockRaftActor.actorDelegate).applyState(eq(mockActorRef), eq(id), anyObject());
+        verify(mockRaftActor.actorDelegate).applyState(eq(mockActorRef), eq(id), any());
     }
 
     @Test
@@ -586,7 +584,7 @@ public class RaftActorTest extends AbstractActorTest {
         leaderActor.getRaftActorContext().getSnapshotManager().capture(
                 new SimpleReplicatedLogEntry(6, 1, new MockRaftActorContext.MockPayload("x")), 4);
 
-        verify(leaderActor.snapshotCohortDelegate).createSnapshot(anyObject(), anyObject());
+        verify(leaderActor.snapshotCohortDelegate).createSnapshot(any(), any());
 
         assertEquals(8, leaderActor.getReplicatedLog().size());
 
@@ -676,7 +674,7 @@ public class RaftActorTest extends AbstractActorTest {
         followerActor.getRaftActorContext().getSnapshotManager().capture(
                 new SimpleReplicatedLogEntry(5, 1, new MockRaftActorContext.MockPayload("D")), 4);
 
-        verify(followerActor.snapshotCohortDelegate).createSnapshot(anyObject(), anyObject());
+        verify(followerActor.snapshotCohortDelegate).createSnapshot(any(), any());
 
         assertEquals(6, followerActor.getReplicatedLog().size());
 
@@ -1062,14 +1060,15 @@ public class RaftActorTest extends AbstractActorTest {
         // Test with timeout
 
         mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(
-                Duration.create(200, TimeUnit.MILLISECONDS));
+            FiniteDuration.create(200, TimeUnit.MILLISECONDS));
         reset(mockRaftActor.snapshotCohortDelegate);
 
         raftActorRef.tell(GetSnapshot.INSTANCE, kit.getRef());
         Failure failure = kit.expectMsgClass(akka.actor.Status.Failure.class);
         assertEquals("Failure cause type", TimeoutException.class, failure.cause().getClass());
 
-        mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(Duration.create(30, TimeUnit.SECONDS));
+        mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(
+            FiniteDuration.create(30, TimeUnit.SECONDS));
 
         // Test with persistence disabled.
 
@@ -1078,7 +1077,7 @@ public class RaftActorTest extends AbstractActorTest {
 
         raftActorRef.tell(GetSnapshot.INSTANCE, kit.getRef());
         reply = kit.expectMsgClass(GetSnapshotReply.class);
-        verify(mockRaftActor.snapshotCohortDelegate, never()).createSnapshot(anyObject(), anyObject());
+        verify(mockRaftActor.snapshotCohortDelegate, never()).createSnapshot(any(), any());
 
         assertEquals("getId", persistenceId, reply.getId());
         replySnapshot = reply.getSnapshot();