Reset snapshot progress after timeout has been hit
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / SnapshotManagerTest.java
index ccbdb5531faaf9f6bd6bd3a4662ee122d3f0db33..0dc33130dae32b491b7acaacf42042fc36ce7b49 100644 (file)
@@ -12,9 +12,8 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
@@ -120,7 +119,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
     @Test
-    public void testCaptureToInstall() throws Exception {
+    public void testCaptureToInstall() {
 
         // Force capturing toInstall = true
         snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(0, 1,
@@ -150,7 +149,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Test
-    public void testCapture() throws Exception {
+    public void testCapture() {
         boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
@@ -181,7 +180,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
     @Test
-    public void testCaptureWithNullLastLogEntry() throws Exception {
+    public void testCaptureWithNullLastLogEntry() {
         boolean capture = snapshotManager.capture(null, 1);
 
         assertTrue(capture);
@@ -209,8 +208,8 @@ public class SnapshotManagerTest extends AbstractActorTest {
     }
 
     @Test
-    public void testCaptureWithCreateProcedureError() throws Exception {
-        doThrow(new RuntimeException("mock")).when(mockProcedure).accept(anyObject());
+    public void testCaptureWithCreateProcedureError() {
+        doThrow(new RuntimeException("mock")).when(mockProcedure).accept(any());
 
         boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
@@ -219,18 +218,18 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
         assertEquals(false, snapshotManager.isCapturing());
 
-        verify(mockProcedure).accept(anyObject());
+        verify(mockProcedure).accept(any());
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testIllegalCapture() throws Exception {
+    public void testIllegalCapture() {
         boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
         assertTrue(capture);
 
-        verify(mockProcedure).accept(anyObject());
+        verify(mockProcedure).accept(any());
 
         reset(mockProcedure);
 
@@ -240,11 +239,11 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
         assertFalse(capture);
 
-        verify(mockProcedure, never()).accept(anyObject());
+        verify(mockProcedure, never()).accept(any());
     }
 
     @Test
-    public void testPersistWhenReplicatedToAllIndexMinusOne() throws Exception {
+    public void testPersistWhenReplicatedToAllIndexMinusOne() {
         doReturn(7L).when(mockReplicatedLog).getSnapshotIndex();
         doReturn(1L).when(mockReplicatedLog).getSnapshotTerm();
 
@@ -284,7 +283,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     }
 
     @Test
-    public void testPersistWhenReplicatedToAllIndexNotMinus() throws Exception {
+    public void testPersistWhenReplicatedToAllIndexNotMinus() {
         doReturn(45L).when(mockReplicatedLog).getSnapshotIndex();
         doReturn(6L).when(mockReplicatedLog).getSnapshotTerm();
         ReplicatedLogEntry replicatedLogEntry = mock(ReplicatedLogEntry.class);
@@ -361,7 +360,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     @Test
     public void testPersistSendInstallSnapshot() throws Exception {
         doReturn(Integer.MAX_VALUE).when(mockReplicatedLog).dataSize();
-        doNothing().when(mockProcedure).accept(anyObject());
+        doNothing().when(mockProcedure).accept(any());
 
         // when replicatedToAllIndex = -1
         boolean capture = snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,