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 java.util.concurrent.Future;
16 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
17 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite {
24 private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node(
28 protected void customizeTask(final DatastoreTestTask task) {
29 task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.ONE);
33 public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
35 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
37 assertNotNull(change);
39 assertNotContains(change.getCreatedData(), TOP_LEVEL);
40 assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR));
42 assertEmpty(change.getUpdatedData());
43 assertEmpty(change.getRemovedPaths());
48 public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
51 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
52 assertNotNull(change);
54 assertContains(change.getCreatedData(), path(FOO, BAZ));
55 assertContains(change.getUpdatedData(), path(FOO));
56 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
57 assertContains(change.getRemovedPaths(), path(FOO, BAR));
62 protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
65 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
66 assertNotNull(change);
67 assertFalse(change.getCreatedData().isEmpty());
69 assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR), path(FOO, BAZ));
70 assertNotContains(change.getCreatedData(), TOP_LEVEL);
71 assertEmpty(change.getUpdatedData());
72 assertEmpty(change.getRemovedPaths());
77 protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
80 Future<?> future = task.getChangeEvent();
82 * One listener should be notified only and only if actual node changed its state,
83 * since deletion of nested child (in this case /nested-list/nested-list[foo],
84 * did not result in change of node we are listening
85 * for, we should not be getting data change event
86 * and this means settable future containing receivedDataChangeEvent is not done.
89 assertFalse(future.isDone());
93 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
96 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
98 assertEmpty(change.getCreatedData());
99 assertEmpty(change.getUpdatedData());
101 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
102 assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR));
106 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
107 Future<?> future = task.getChangeEvent();
109 * One listener should be notified only and only if actual node changed its state,
110 * since deletion of nested child (in this case /nested-list/nested-list[foo],
111 * did not result in change of node we are listening
112 * for, we should not be getting data change event
113 * and this means settable future containing receivedDataChangeEvent is not done.
116 assertFalse(future.isDone());
120 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
121 Future<?> future = task.getChangeEvent();
123 * One listener should be notified only and only if actual node changed its state,
124 * since deletion of nested child (in this case /nested-list/nested-list[foo],
125 * did not result in change of node we are listening
126 * for, we should not be getting data change event
127 * and this means settable future containing receivedDataChangeEvent is not done.
130 assertFalse(future.isDone());
134 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
135 AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
137 assertContains(change.getCreatedData(), path(FOO_SIBLING));
138 assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL);
139 assertEmpty(change.getRemovedPaths());