Convert DatastoreSnapshotRestore to OSGi DS
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ShardTest.java
index b3e8de2d9b70af550bfa0017ed3a0d873125da83..6429307dc1d3c8cca783eddcecdc1e22c5f710d3 100644 (file)
@@ -169,7 +169,7 @@ public class ShardTest extends AbstractShardTest {
     public void testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration() throws Exception {
         final CountDownLatch onFirstElectionTimeout = new CountDownLatch(1);
         final CountDownLatch onChangeListenerRegistered = new CountDownLatch(1);
-        final Creator<Shard> creator = new Creator<Shard>() {
+        final Creator<Shard> creator = new Creator<>() {
             boolean firstElectionTimeout = true;
 
             @Override
@@ -202,8 +202,8 @@ public class ShardTest extends AbstractShardTest {
         final ActorRef dclActor = actorFactory.createActor(DataTreeChangeListenerActor.props(listener, path),
                 "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration-DataChangeListener");
 
-        final TestActorRef<Shard> shard = actorFactory.createTestActor(
-                Props.create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
+        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props.create(Shard.class,
+                new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 "testDataTreeChangeListenerNotifiedWhenNotTheLeaderOnRegistration");
 
         final ShardTestKit testKit = new ShardTestKit(getSystem());
@@ -299,7 +299,7 @@ public class ShardTest extends AbstractShardTest {
 
         writeToStore(store, TestModel.TEST_PATH, container);
 
-        final YangInstanceIdentifier root = YangInstanceIdentifier.EMPTY;
+        final YangInstanceIdentifier root = YangInstanceIdentifier.empty();
         final NormalizedNode<?,?> expected = readStore(store, root);
 
         final Snapshot snapshot = Snapshot.create(new ShardSnapshotState(new MetadataShardDataTreeSnapshot(expected)),
@@ -551,7 +551,7 @@ public class ShardTest extends AbstractShardTest {
 
         verifyOuterListEntry(shard, 1);
 
-        verifyLastApplied(shard, 5);
+        verifyLastApplied(shard, 3);
     }
 
     @Test
@@ -757,7 +757,7 @@ public class ShardTest extends AbstractShardTest {
     public void testOnBatchedModificationsWhenNotLeader() {
         final AtomicBoolean overrideLeaderCalls = new AtomicBoolean();
         final ShardTestKit testKit = new ShardTestKit(getSystem());
-        final Creator<Shard> creator = new Creator<Shard>() {
+        final Creator<Shard> creator = new Creator<>() {
             private static final long serialVersionUID = 1L;
 
             @Override
@@ -777,8 +777,8 @@ public class ShardTest extends AbstractShardTest {
             }
         };
 
-        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props
-            .create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
+        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props.create(Shard.class,
+            new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
             "testOnBatchedModificationsWhenNotLeader");
 
         ShardTestKit.waitUntilLeader(shard);
@@ -1026,8 +1026,7 @@ public class ShardTest extends AbstractShardTest {
         // Committed transaction count should increase as usual
         assertEquals(1, shardStats.getCommittedTransactionsCount());
 
-        // Commit index should advance as we do not have an empty
-        // modification
+        // Commit index should advance 1 to account for disabling metadata
         assertEquals(1, shardStats.getCommitIndex());
     }
 
@@ -1085,7 +1084,7 @@ public class ShardTest extends AbstractShardTest {
         // Wait for the 2nd Tx to complete the canCommit phase.
 
         final CountDownLatch latch = new CountDownLatch(1);
-        canCommitFuture.onComplete(new OnComplete<Object>() {
+        canCommitFuture.onComplete(new OnComplete<>() {
             @Override
             public void onComplete(final Throwable failure, final Object resp) {
                 latch.countDown();
@@ -1155,7 +1154,7 @@ public class ShardTest extends AbstractShardTest {
         // Wait for the 2nd Tx to complete the canCommit phase.
 
         final CountDownLatch latch = new CountDownLatch(1);
-        canCommitFuture.onComplete(new OnComplete<Object>() {
+        canCommitFuture.onComplete(new OnComplete<>() {
             @Override
             public void onComplete(final Throwable failure, final Object resp) {
                 latch.countDown();
@@ -1183,7 +1182,7 @@ public class ShardTest extends AbstractShardTest {
         final Duration duration = Duration.ofSeconds(5);
         final TransactionIdentifier transactionID1 = nextTransactionId();
 
-        doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "mock canCommit failure"))
+        doThrow(new DataValidationFailedException(YangInstanceIdentifier.empty(), "mock canCommit failure"))
         .doNothing().when(dataTree).validate(any(DataTreeModification.class));
 
         shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
@@ -1224,7 +1223,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "mock canCommit failure"))
+        doThrow(new DataValidationFailedException(YangInstanceIdentifier.empty(), "mock canCommit failure"))
         .doNothing().when(dataTree).validate(any(DataTreeModification.class));
 
         final Duration duration = Duration.ofSeconds(5);
@@ -1273,8 +1272,8 @@ public class ShardTest extends AbstractShardTest {
             }
         };
 
-        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props
-            .create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
+        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props.create(Shard.class,
+            new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
             "testAbortWithCommitPending");
 
         ShardTestKit.waitUntilLeader(shard);
@@ -1731,14 +1730,13 @@ public class ShardTest extends AbstractShardTest {
 
         final Creator<Shard> creator = () -> new TestShard(newShardBuilder());
 
-        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props
-            .create(new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()),
-            shardActorName);
+        final TestActorRef<Shard> shard = actorFactory.createTestActor(Props.create(Shard.class,
+            new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()), shardActorName);
 
         ShardTestKit.waitUntilLeader(shard);
         writeToStore(shard, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
-        final NormalizedNode<?, ?> expectedRoot = readStore(shard, YangInstanceIdentifier.EMPTY);
+        final NormalizedNode<?, ?> expectedRoot = readStore(shard, YangInstanceIdentifier.empty());
 
         // Trigger creation of a snapshot by ensuring
         final RaftActorContext raftActorContext = ((TestShard) shard.underlyingActor()).getRaftActorContext();
@@ -1781,16 +1779,16 @@ public class ShardTest extends AbstractShardTest {
         commitTransaction(store, putTransaction);
 
 
-        final NormalizedNode<?, ?> expected = readStore(store, YangInstanceIdentifier.EMPTY);
+        final NormalizedNode<?, ?> expected = readStore(store, YangInstanceIdentifier.empty());
 
         final DataTreeModification writeTransaction = store.takeSnapshot().newModification();
 
-        writeTransaction.delete(YangInstanceIdentifier.EMPTY);
-        writeTransaction.write(YangInstanceIdentifier.EMPTY, expected);
+        writeTransaction.delete(YangInstanceIdentifier.empty());
+        writeTransaction.write(YangInstanceIdentifier.empty(), expected);
 
         commitTransaction(store, writeTransaction);
 
-        final NormalizedNode<?, ?> actual = readStore(store, YangInstanceIdentifier.EMPTY);
+        final NormalizedNode<?, ?> actual = readStore(store, YangInstanceIdentifier.empty());
 
         assertEquals(expected, actual);
     }