Migrate from YangInstanceIdentifier.EMPTY
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ShardTest.java
index 7d4c054b3e9a4e86728feb9e5936ae9550cee888..6e3782b0aed60920cfd967e10406a6c9ce2d5360 100644 (file)
@@ -150,6 +150,18 @@ public class ShardTest extends AbstractShardTest {
         writeToStore(shard, path, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
         listener.waitForChangeEvents();
+        listener.verifyOnInitialDataEvent();
+
+        final MockDataTreeChangeListener listener2 = new MockDataTreeChangeListener(1);
+        final ActorRef dclActor2 = actorFactory.createActor(DataTreeChangeListenerActor.props(listener2,
+            TestModel.TEST_PATH), "testRegisterDataTreeChangeListener-DataTreeChangeListener2");
+
+        shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor2, false), testKit.getRef());
+
+        testKit.expectMsgClass(Duration.ofSeconds(3), RegisterDataTreeNotificationListenerReply.class);
+
+        listener2.waitForChangeEvents();
+        listener2.verifyNoOnInitialDataEvent();
     }
 
     @SuppressWarnings("serial")
@@ -287,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)),
@@ -539,7 +551,7 @@ public class ShardTest extends AbstractShardTest {
 
         verifyOuterListEntry(shard, 1);
 
-        verifyLastApplied(shard, 5);
+        verifyLastApplied(shard, 3);
     }
 
     @Test
@@ -1014,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());
     }
 
@@ -1171,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,
@@ -1212,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);
@@ -1726,7 +1737,7 @@ public class ShardTest extends AbstractShardTest {
         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();
@@ -1769,16 +1780,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);
     }