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 WildcardedScopeOneTest 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.ONE);
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 * One listener should be notified only and only if actual node changed its state,
80 * since deletion of nested child (in this case /nested-list/nested-list[foo],
81 * did not result in change of node we are listening
82 * for, we should not be getting data change event
83 * and this means settable future containing receivedDataChangeEvent is not done.
86 task.verifyNoChangeEvent();
90 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
93 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
95 assertEmpty(change.getCreatedData());
96 assertEmpty(change.getUpdatedData());
98 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
99 assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR));
103 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
105 * One listener should be notified only and only if actual node changed its state,
106 * since deletion of nested child (in this case /nested-list/nested-list[foo],
107 * did not result in change of node we are listening
108 * for, we should not be getting data change event
109 * and this means settable future containing receivedDataChangeEvent is not done.
112 task.verifyNoChangeEvent();
116 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
118 * One listener should be notified only and only if actual node changed its state,
119 * since deletion of nested child (in this case /nested-list/nested-list[foo],
120 * did not result in change of node we are listening
121 * for, we should not be getting data change event
122 * and this means settable future containing receivedDataChangeEvent is not done.
125 task.verifyNoChangeEvent();
129 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
130 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
132 assertContains(change.getCreatedData(), path(FOO_SIBLING));
133 assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL);
134 assertEmpty(change.getRemovedPaths());