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=23c35f3ed3ad78a4d57ac0aceac6368d392d8a27;hp=ddbba76ae035b752701530d46104dc8c0bdec639;hb=refs%2Fchanges%2F00%2F71800%2F2;hpb=a3ebcb3c36804de1e4c0177f3462e33958b0c216 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 ddbba76ae0..23c35f3ed3 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 @@ -7,145 +7,95 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.added; +import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.deleted; +import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.replaced; -import java.util.concurrent.ExecutionException; -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; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite { +public class WildcardedScopeBaseTest extends DefaultDataTreeChangeListenerTestSuite { private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node( TopLevelList.QNAME); @Override - protected void customizeTask(final DatastoreTestTask task) { - task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.BASE); + protected void putTopLevelOneNestedSetup(final DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); } @Override - public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - - AsyncDataChangeEvent> change = task.getChangeEvent(); - - assertNotNull(change); - - /* - * 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()); - + protected void putTopLevelOneNestedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); } @Override - public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { - - AsyncDataChangeEvent> change = task.getChangeEvent(); - assertNotNull(change); - /* - * 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); - /* - * Removed data must NOT contain nested-list item since scope is base, and change is two - * level deep. - */ - assertNotContains(change.getRemovedPaths(), path(FOO, BAR)); - + protected void replaceTopLevelNestedSetup(DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), replaced(path(FOO))); } @Override - protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { - - AsyncDataChangeEvent> change = task.getChangeEvent(); - assertNotNull(change); - assertFalse(change.getCreatedData().isEmpty()); + protected void replaceTopLevelNestedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); + } - // 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()); + @Override + protected void putTopLevelWithTwoNestedSetup(final DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); + } + @Override + protected void putTopLevelWithTwoNestedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); } @Override - protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); + } - /* - * 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 - * for, we should not be getting data change event - * and this means settable future containing receivedDataChangeEvent is not done. - * - */ - task.verifyNoChangeEvent(); + @Override + protected void twoNestedExistsOneIsDeletedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); } @Override - public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void nestedListExistsRootDeletedSetup(DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), deleted(path(FOO))); + } - AsyncDataChangeEvent> change = task.getChangeEvent(); + @Override + protected void nestedListExistsRootDeletedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); + } - assertEmpty(change.getCreatedData()); - assertEmpty(change.getUpdatedData()); + @Override + protected void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); + } - assertNotContains(change.getUpdatedData(), TOP_LEVEL); - /* - * 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 existingOneNestedWriteAdditionalNestedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); } @Override - protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) { - /* - * 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], - * did not result in change of node we are listening - * for, we should not be getting data change event - * and this means settable future containing receivedDataChangeEvent is not done. - * - */ - task.verifyNoChangeEvent(); + protected void existingTopWriteTwoNestedSetup(DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO))); } @Override - protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - /* - * 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], - * did not result in change of node we are listening - * for, we should not be getting data change event - * and this means settable future containing receivedDataChangeEvent is not done. - * - */ - task.verifyNoChangeEvent(); + protected void existingTopWriteTwoNestedVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); } @Override - protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { - AsyncDataChangeEvent> change = task.getChangeEvent(); + protected void existingTopWriteSiblingSetup(DatastoreTestTask task) { + task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), added(path(FOO_SIBLING))); + } - assertContains(change.getCreatedData(), path(FOO_SIBLING)); - assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL); - assertEmpty(change.getRemovedPaths()); + @Override + protected void existingTopWriteSiblingVerify(final DatastoreTestTask task) { + task.verifyChangeEvents(); } }