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.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite {
21 private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TestModel.OUTER_LIST_QNAME).node(
22 TestModel.OUTER_LIST_QNAME);
25 protected void customizeTask(final DatastoreTestTask task) {
26 task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.BASE);
30 public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
32 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
34 assertNotNull(change);
37 * Created data must not contain nested-list item, since that is two-level deep.
39 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR));
40 assertContains(change.getCreatedData(), path(FOO) );
42 assertEmpty(change.getUpdatedData());
43 assertEmpty(change.getRemovedPaths());
48 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
51 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
52 assertNotNull(change);
54 * Created data must NOT contain nested-list item since scope is base, and change is two
57 assertNotContains(change.getCreatedData(), path(FOO, BAZ));
58 assertContains(change.getUpdatedData(), path(FOO));
59 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
61 * Removed data must NOT contain nested-list item since scope is base, and change is two
64 assertNotContains(change.getRemovedPaths(), path(FOO, BAR));
69 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
72 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
73 assertNotNull(change);
74 assertFalse(change.getCreatedData().isEmpty());
76 // Base event should contain only changed item, no details about child.
77 assertContains(change.getCreatedData(), path(FOO));
78 assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR), path(FOO, BAZ));
79 assertEmpty(change.getUpdatedData());
80 assertEmpty(change.getRemovedPaths());
85 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
89 * Base listener should be notified only and only if actual node changed its state,
90 * since deletion of child, 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 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
104 assertEmpty(change.getCreatedData());
105 assertEmpty(change.getUpdatedData());
107 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
109 * Scope base listener event should contain top-level-list item and nested list path
110 * and should not contain baz, bar which are two-level deep
112 assertContains(change.getRemovedPaths(), path(FOO));
113 assertNotContains(change.getRemovedPaths(),path(FOO, BAZ),path(FOO,BAR));
117 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
119 * One listener should be notified only and only if actual node changed its state,
120 * since deletion of nested child (in this case /nested-list/nested-list[foo],
121 * did not result in change of node we are listening
122 * for, we should not be getting data change event
123 * and this means settable future containing receivedDataChangeEvent is not done.
126 task.verifyNoChangeEvent();
130 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
132 * One listener should be notified only and only if actual node changed its state,
133 * since deletion of nested child (in this case /nested-list/nested-list[foo],
134 * did not result in change of node we are listening
135 * for, we should not be getting data change event
136 * and this means settable future containing receivedDataChangeEvent is not done.
139 task.verifyNoChangeEvent();
143 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
144 final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
146 assertContains(change.getCreatedData(), path(FOO_SIBLING));
147 assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL);
148 assertEmpty(change.getRemovedPaths());