2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl;
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertNotNull;
13 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite {
22 private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node(
26 protected void customizeTask(final DatastoreTestTask task) {
27 task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.ONE);
31 public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception {
33 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
35 assertNotNull(change);
37 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR));
38 assertContains(change.getCreatedData(), path(FOO), path(FOO).node(NestedList.QNAME));
40 assertEmpty(change.getUpdatedData());
41 assertEmpty(change.getRemovedPaths());
46 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception {
48 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
49 assertNotNull(change);
51 * Created data must NOT contain nested-list item since scope is base, and change is two
54 assertNotContains(change.getCreatedData(), path(FOO, BAZ));
55 assertContains(change.getUpdatedData(), path(FOO),path(FOO).node(NestedList.QNAME));
56 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
58 * Removed data must NOT contain nested-list item since scope is base, and change is two
61 assertNotContains(change.getRemovedPaths(), path(FOO, BAR));
66 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception {
68 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
69 assertNotNull(change);
70 assertFalse(change.getCreatedData().isEmpty());
72 // Base event should contain only changed item, and details about immediate child.
73 assertContains(change.getCreatedData(), path(FOO),path(FOO).node(NestedList.QNAME));
74 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR), path(FOO, BAZ));
75 assertEmpty(change.getUpdatedData());
76 assertEmpty(change.getRemovedPaths());
81 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception {
84 * One listener should be notified only and only if actual node changed its state,
85 * since deletion of nested child (in this case /nested-list/nested-list[foo],
86 * did not result in change of node we are listening
87 * for, we should not be getting data change event
88 * and this means settable future containing receivedDataChangeEvent is not done.
91 task.verifyNoChangeEvent();
95 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception {
97 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
99 assertEmpty(change.getCreatedData());
100 assertEmpty(change.getUpdatedData());
102 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
103 assertContains(change.getRemovedPaths(), path(FOO),path(FOO).node(NestedList.QNAME));
104 assertNotContains(change.getRemovedPaths(), path(FOO, BAZ),path(FOO,BAR));
108 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception {
110 * One listener should be notified only and only if actual node changed its state,
111 * since deletion of nested child (in this case /nested-list/nested-list[foo],
112 * did not result in change of node we are listening
113 * for, we should not be getting data change event
114 * and this means settable future containing receivedDataChangeEvent is not done.
117 task.verifyNoChangeEvent();
121 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception {
123 * One listener should be notified only and only if actual node changed its state,
124 * since deletion of nested child (in this case /nested-list/nested-list[foo],
125 * did not result in change of node we are listening
126 * for, we should not be getting data change event
127 * and this means settable future containing receivedDataChangeEvent is not done.
130 task.verifyNoChangeEvent();
134 protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception {
135 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
137 assertContains(change.getCreatedData(), path(FOO_SIBLING));
138 assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL);
139 assertEmpty(change.getRemovedPaths());