Migrate most of CDS to use java.util.Optional
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ShardTest.java
index bdae31c96fbc54fada222f51d3cf6aea9b61562c..46fdfacbe956497db88acba4e9d2de831aa6991e 100644 (file)
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
@@ -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")
@@ -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());
     }