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);
37 assertNotContains(change.getCreatedData(), TOP_LEVEL);
38 assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR));
40 assertEmpty(change.getUpdatedData());
41 assertEmpty(change.getRemovedPaths());
46 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
49 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
50 assertNotNull(change);
52 assertContains(change.getCreatedData(), path(FOO, BAZ));
53 assertContains(change.getUpdatedData(), path(FOO));
54 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
55 assertContains(change.getRemovedPaths(), path(FOO, BAR));
60 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
63 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
64 assertNotNull(change);
65 assertFalse(change.getCreatedData().isEmpty());
67 assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR), path(FOO, BAZ));
68 assertNotContains(change.getCreatedData(), TOP_LEVEL);
69 assertEmpty(change.getUpdatedData());
70 assertEmpty(change.getRemovedPaths());
75 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
79 * Base listener should be notified only and only if actual node changed its state,
80 * since deletion of child, did not result in change of node we are listening
81 * for, we should not be getting data change event
82 * and this means settable future containing receivedDataChangeEvent is not done.
85 task.verifyNoChangeEvent();
89 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
92 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
94 assertEmpty(change.getCreatedData());
95 assertEmpty(change.getUpdatedData());
97 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
98 assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR));
102 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
104 * One listener should be notified only and only if actual node changed its state,
105 * since deletion of nested child (in this case /nested-list/nested-list[foo],
106 * did not result in change of node we are listening
107 * for, we should not be getting data change event
108 * and this means settable future containing receivedDataChangeEvent is not done.
111 task.verifyNoChangeEvent();
115 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
117 * One listener should be notified only and only if actual node changed its state,
118 * since deletion of nested child (in this case /nested-list/nested-list[foo],
119 * did not result in change of node we are listening
120 * for, we should not be getting data change event
121 * and this means settable future containing receivedDataChangeEvent is not done.
124 task.verifyNoChangeEvent();
128 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
129 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
131 assertContains(change.getCreatedData(), path(FOO_SIBLING));
132 assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL);
133 assertEmpty(change.getRemovedPaths());