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.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 public class WildcardedScopeBaseTest 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.BASE);
31 public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
33 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
35 assertNotNull(change);
38 * Created data must not contain nested-list item, since that is two-level deep.
40 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR));
41 assertContains(change.getCreatedData(), path(FOO) );
43 assertEmpty(change.getUpdatedData());
44 assertEmpty(change.getRemovedPaths());
49 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
52 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
53 assertNotNull(change);
55 * Created data must NOT contain nested-list item since scope is base, and change is two
58 assertNotContains(change.getCreatedData(), path(FOO, BAZ));
59 assertContains(change.getUpdatedData(), path(FOO));
60 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
62 * Removed data must NOT contain nested-list item since scope is base, and change is two
65 assertNotContains(change.getRemovedPaths(), path(FOO, BAR));
70 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
73 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
74 assertNotNull(change);
75 assertFalse(change.getCreatedData().isEmpty());
77 // Base event should contain only changed item, no details about child.
78 assertContains(change.getCreatedData(), path(FOO));
79 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR), path(FOO, BAZ));
80 assertEmpty(change.getUpdatedData());
81 assertEmpty(change.getRemovedPaths());
86 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
90 * Base listener should be notified only and only if actual node changed its state,
91 * since deletion of child, did not result in change of node we are listening
92 * for, we should not be getting data change event
93 * and this means settable future containing receivedDataChangeEvent is not done.
96 task.verifyNoChangeEvent();
100 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
103 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
105 assertEmpty(change.getCreatedData());
106 assertEmpty(change.getUpdatedData());
108 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
110 * Scope base listener event should contain top-level-list item and nested list path
111 * and should not contain baz, bar which are two-level deep
113 assertContains(change.getRemovedPaths(), path(FOO));
114 assertNotContains(change.getRemovedPaths(),path(FOO, BAZ),path(FOO,BAR));
118 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
120 * One listener should be notified only and only if actual node changed its state,
121 * since deletion of nested child (in this case /nested-list/nested-list[foo],
122 * did not result in change of node we are listening
123 * for, we should not be getting data change event
124 * and this means settable future containing receivedDataChangeEvent is not done.
127 task.verifyNoChangeEvent();
131 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
133 * One listener should be notified only and only if actual node changed its state,
134 * since deletion of nested child (in this case /nested-list/nested-list[foo],
135 * did not result in change of node we are listening
136 * for, we should not be getting data change event
137 * and this means settable future containing receivedDataChangeEvent is not done.
140 task.verifyNoChangeEvent();
144 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
145 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
147 assertContains(change.getCreatedData(), path(FOO_SIBLING));
148 assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL);
149 assertEmpty(change.getRemovedPaths());