X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FWildcardedScopeBaseTest.java;h=ddbba76ae035b752701530d46104dc8c0bdec639;hp=7c8676eff56728f9b5307e177f9ffcbd0c4bb87f;hb=978152c5de3bf78ab6da5da4c2db391eec063429;hpb=c46e223995956f1f759c551163c212947c1e2fb7 diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java index 7c8676eff5..ddbba76ae0 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java @@ -11,8 +11,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; @@ -32,12 +30,15 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite @Override public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); - assertNotContains(change.getCreatedData(), TOP_LEVEL); - assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR)); + /* + * Created data must not contain nested-list item, since that is two-level deep. + */ + assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR)); + assertContains(change.getCreatedData(), path(FOO) ); assertEmpty(change.getUpdatedData()); assertEmpty(change.getRemovedPaths()); @@ -48,13 +49,20 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); - - assertContains(change.getCreatedData(), path(FOO, BAZ)); + /* + * Created data must NOT contain nested-list item since scope is base, and change is two + * level deep. + */ + assertNotContains(change.getCreatedData(), path(FOO, BAZ)); assertContains(change.getUpdatedData(), path(FOO)); assertNotContains(change.getUpdatedData(), TOP_LEVEL); - assertContains(change.getRemovedPaths(), path(FOO, BAR)); + /* + * Removed data must NOT contain nested-list item since scope is base, and change is two + * level deep. + */ + assertNotContains(change.getRemovedPaths(), path(FOO, BAR)); } @@ -62,12 +70,13 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); assertFalse(change.getCreatedData().isEmpty()); - assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR), path(FOO, BAZ)); - assertNotContains(change.getCreatedData(), TOP_LEVEL); + // Base event should contain only changed item, no details about child. + assertContains(change.getCreatedData(), path(FOO)); + assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR), path(FOO, BAZ)); assertEmpty(change.getUpdatedData()); assertEmpty(change.getRemovedPaths()); @@ -77,7 +86,6 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - Future future = task.getChangeEvent(); /* * Base listener should be notified only and only if actual node changed its state, * since deletion of child, did not result in change of node we are listening @@ -85,25 +93,29 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite * and this means settable future containing receivedDataChangeEvent is not done. * */ - assertFalse(future.isDone()); + task.verifyNoChangeEvent(); } @Override public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent(); assertEmpty(change.getCreatedData()); assertEmpty(change.getUpdatedData()); assertNotContains(change.getUpdatedData(), TOP_LEVEL); - assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR)); + /* + * Scope base listener event should contain top-level-list item and nested list path + * and should not contain baz, bar which are two-level deep + */ + assertContains(change.getRemovedPaths(), path(FOO)); + assertNotContains(change.getRemovedPaths(),path(FOO, BAZ),path(FOO,BAR)); } @Override protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) { - Future future = task.getChangeEvent(); /* * One listener should be notified only and only if actual node changed its state, * since deletion of nested child (in this case /nested-list/nested-list[foo], @@ -112,12 +124,11 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite * and this means settable future containing receivedDataChangeEvent is not done. * */ - assertFalse(future.isDone()); + task.verifyNoChangeEvent(); } @Override protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - Future future = task.getChangeEvent(); /* * One listener should be notified only and only if actual node changed its state, * since deletion of nested child (in this case /nested-list/nested-list[foo], @@ -126,12 +137,12 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite * and this means settable future containing receivedDataChangeEvent is not done. * */ - assertFalse(future.isDone()); + task.verifyNoChangeEvent(); } @Override protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent().get(); + AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL);