Seal Snapshot 30/103530/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Dec 2022 16:57:24 +0000 (17:57 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Dec 2022 16:59:30 +0000 (17:59 +0100)
We do not want people to subclass this class, make sure it is sealed.

Change-Id: I81e8a2ba5232471a8f153a710d957e3cb22bbb5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/Snapshot.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java

index 0acede1086ef20f3de26531cb7baf95a5f850507..cf7cc3ea9ef1abcb84063263b06b12758e693e88 100644 (file)
@@ -22,8 +22,7 @@ import org.opendaylight.controller.cluster.raft.messages.Payload;
  *
  * @author Thomas Pantelis
  */
-// Not final and non-sealed for mocking
-public class Snapshot implements Serializable {
+public sealed class Snapshot implements Serializable {
     /**
      * Implementations of this interface are used as the state payload for a snapshot.
      *
index 96e04df15a803855a1b8dca4d71c20e29de4e613..22d9833c2b7ad001b3b095e29e5777b2eda81112 100644 (file)
@@ -336,7 +336,8 @@ public class RaftActorTest extends AbstractActorTest {
         // Wait for akka's recovery to complete so it doesn't interfere.
         mockRaftActor.waitForRecoveryComplete();
 
-        ApplySnapshot applySnapshot = new ApplySnapshot(mock(Snapshot.class));
+        ApplySnapshot applySnapshot = new ApplySnapshot(
+            Snapshot.create(null, null, 0, 0, 0, 0, 0, persistenceId, null));
         doReturn(true).when(mockSupport).handleSnapshotMessage(same(applySnapshot), any(ActorRef.class));
         mockRaftActor.handleCommand(applySnapshot);