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.mdsal.common.api.AsyncDataChangeEvent;
14 import org.opendaylight.mdsal.common.api.AsyncDataBroker.DataChangeScope;
16 import java.util.concurrent.ExecutionException;
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(TestModel.OUTER_LIST_QNAME).node(
23 TestModel.OUTER_LIST_QNAME);
26 protected void customizeTask(final DatastoreTestTask task) {
27 task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.ONE);
31 public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
33 final 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(TestModel.INNER_LIST_QNAME));
40 assertEmpty(change.getUpdatedData());
41 assertEmpty(change.getRemovedPaths());
46 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
49 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
50 assertNotNull(change);
52 * Created data must NOT contain nested-list item since scope is base, and change is two
55 assertNotContains(change.getCreatedData(), path(FOO, BAZ));
56 assertContains(change.getUpdatedData(), path(FOO), path(FOO).node(TestModel.INNER_LIST_QNAME));
57 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
59 * Removed data must NOT contain nested-list item since scope is base, and change is two
62 assertNotContains(change.getRemovedPaths(), path(FOO, BAR));
67 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
70 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
71 assertNotNull(change);
72 assertFalse(change.getCreatedData().isEmpty());
74 // Base event should contain only changed item, and details about immediate child.
75 assertContains(change.getCreatedData(), path(FOO), path(FOO).node(TestModel.INNER_LIST_QNAME));
76 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR), path(FOO, BAZ));
77 assertEmpty(change.getUpdatedData());
78 assertEmpty(change.getRemovedPaths());
83 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
87 * One listener should be notified only and only if actual node changed its state,
88 * since deletion of nested child (in this case /nested-list/nested-list[foo],
89 * did not result in change of node we are listening
90 * for, we should not be getting data change event
91 * and this means settable future containing receivedDataChangeEvent is not done.
94 task.verifyNoChangeEvent();
98 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
101 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
103 assertEmpty(change.getCreatedData());
104 assertEmpty(change.getUpdatedData());
106 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
107 assertContains(change.getRemovedPaths(), path(FOO), path(FOO).node(TestModel.INNER_LIST_QNAME));
108 assertNotContains(change.getRemovedPaths(), path(FOO, BAZ),path(FOO,BAR));
112 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
114 * One listener should be notified only and only if actual node changed its state,
115 * since deletion of nested child (in this case /nested-list/nested-list[foo],
116 * did not result in change of node we are listening
117 * for, we should not be getting data change event
118 * and this means settable future containing receivedDataChangeEvent is not done.
121 task.verifyNoChangeEvent();
125 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
127 * One listener should be notified only and only if actual node changed its state,
128 * since deletion of nested child (in this case /nested-list/nested-list[foo],
129 * did not result in change of node we are listening
130 * for, we should not be getting data change event
131 * and this means settable future containing receivedDataChangeEvent is not done.
134 task.verifyNoChangeEvent();
138 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
139 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
141 assertContains(change.getCreatedData(), path(FOO_SIBLING));
142 assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL);
143 assertEmpty(change.getRemovedPaths());