X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FMockDataTreeChangeListener.java;h=cf188b339e2d5b3c420634919b6e46b8b2ba2d05;hp=d06fc435720fca6d40f0b7cb54e33f64b8307c8a;hb=d9ea4400df226eb65c964ab0cb2aa81ee495ba15;hpb=412db94945c5db5d2da918f5e23bd3abcecc4d10 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java index d06fc43572..cf188b339e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/MockDataTreeChangeListener.java @@ -7,20 +7,23 @@ */ package org.opendaylight.controller.cluster.datastore.utils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; import com.google.common.collect.Lists; import com.google.common.util.concurrent.Uninterruptibles; -import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; - -import javax.annotation.Nonnull; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import javax.annotation.Nonnull; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; public class MockDataTreeChangeListener implements DOMDataTreeChangeListener { @@ -54,8 +57,31 @@ public class MockDataTreeChangeListener implements DOMDataTreeChangeListener { } } + public void verifyNotifiedData(YangInstanceIdentifier... paths) { + Set pathSet = new HashSet<>(Arrays.asList(paths)); + for(Collection list: changeList) { + for(DataTreeCandidate c: list) { + pathSet.remove(c.getRootPath()); + } + } + + if(!pathSet.isEmpty()) { + fail(pathSet + " not present in " + changeList); + } + } + public void expectNoMoreChanges(String assertMsg) { - Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); + Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); assertEquals(assertMsg, expChangeEventCount, changeList.size()); } + + public void verifyNoNotifiedData(YangInstanceIdentifier... paths) { + Set pathSet = new HashSet<>(Arrays.asList(paths)); + for(Collection list: changeList) { + for(DataTreeCandidate c: list) { + assertFalse("Unexpected " + c.getRootPath() + " present in DataTreeCandidate", + pathSet.contains(c.getRootPath())); + } + } + } }