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 java.util.concurrent.ExecutionException;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
15 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
17 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;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite {
23 private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node(
27 protected void customizeTask(final DatastoreTestTask task) {
28 task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.ONE);
32 public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
34 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
36 assertNotNull(change);
38 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR));
39 assertContains(change.getCreatedData(), path(FOO), path(FOO).node(NestedList.QNAME));
41 assertEmpty(change.getUpdatedData());
42 assertEmpty(change.getRemovedPaths());
47 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
50 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
51 assertNotNull(change);
53 * Created data must NOT contain nested-list item since scope is base, and change is two
56 assertNotContains(change.getCreatedData(), path(FOO, BAZ));
57 assertContains(change.getUpdatedData(), path(FOO),path(FOO).node(NestedList.QNAME));
58 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
60 * Removed data must NOT contain nested-list item since scope is base, and change is two
63 assertNotContains(change.getRemovedPaths(), path(FOO, BAR));
68 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
71 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
72 assertNotNull(change);
73 assertFalse(change.getCreatedData().isEmpty());
75 // Base event should contain only changed item, and details about immediate child.
76 assertContains(change.getCreatedData(), path(FOO),path(FOO).node(NestedList.QNAME));
77 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR), path(FOO, BAZ));
78 assertEmpty(change.getUpdatedData());
79 assertEmpty(change.getRemovedPaths());
84 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
88 * One listener should be notified only and only if actual node changed its state,
89 * since deletion of nested child (in this case /nested-list/nested-list[foo],
90 * did not result in change of node we are listening
91 * for, we should not be getting data change event
92 * and this means settable future containing receivedDataChangeEvent is not done.
95 task.verifyNoChangeEvent();
99 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
102 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
104 assertEmpty(change.getCreatedData());
105 assertEmpty(change.getUpdatedData());
107 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
108 assertContains(change.getRemovedPaths(), path(FOO),path(FOO).node(NestedList.QNAME));
109 assertNotContains(change.getRemovedPaths(), path(FOO, BAZ),path(FOO,BAR));
113 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
115 * One listener should be notified only and only if actual node changed its state,
116 * since deletion of nested child (in this case /nested-list/nested-list[foo],
117 * did not result in change of node we are listening
118 * for, we should not be getting data change event
119 * and this means settable future containing receivedDataChangeEvent is not done.
122 task.verifyNoChangeEvent();
126 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
128 * One listener should be notified only and only if actual node changed its state,
129 * since deletion of nested child (in this case /nested-list/nested-list[foo],
130 * did not result in change of node we are listening
131 * for, we should not be getting data change event
132 * and this means settable future containing receivedDataChangeEvent is not done.
135 task.verifyNoChangeEvent();
139 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
140 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
142 assertContains(change.getCreatedData(), path(FOO_SIBLING));
143 assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL);
144 assertEmpty(change.getRemovedPaths());