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.InstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite {
24 private static final InstanceIdentifier 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.BASE);
33 public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
35 AsyncDataChangeEvent<InstanceIdentifier, 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<InstanceIdentifier, 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<InstanceIdentifier, 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 * Base listener should be notified only and only if actual node changed its state,
83 * since deletion of child, did not result in change of node we are listening
84 * for, we should not be getting data change event
85 * and this means settable future containing receivedDataChangeEvent is not done.
88 assertFalse(future.isDone());
92 public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
95 AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
97 assertEmpty(change.getCreatedData());
98 assertEmpty(change.getUpdatedData());
100 assertNotContains(change.getUpdatedData(), TOP_LEVEL);
101 assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR));
105 protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
106 Future<?> future = task.getChangeEvent();
108 * One listener should be notified only and only if actual node changed its state,
109 * since deletion of nested child (in this case /nested-list/nested-list[foo],
110 * did not result in change of node we are listening
111 * for, we should not be getting data change event
112 * and this means settable future containing receivedDataChangeEvent is not done.
115 assertFalse(future.isDone());
119 protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
120 Future<?> future = task.getChangeEvent();
122 * One listener should be notified only and only if actual node changed its state,
123 * since deletion of nested child (in this case /nested-list/nested-list[foo],
124 * did not result in change of node we are listening
125 * for, we should not be getting data change event
126 * and this means settable future containing receivedDataChangeEvent is not done.
129 assertFalse(future.isDone());
133 protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
134 AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent().get();
136 assertContains(change.getCreatedData(), path(FOO_SIBLING));
137 assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL);
138 assertEmpty(change.getRemovedPaths());