Merge "Missing capability in 10-rest-connector.xml file"
[controller.git] / opendaylight / md-sal / sal-inmemory-datastore / src / test / java / org / opendaylight / controller / md / sal / dom / store / impl / WildcardedScopeOneTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl;
9
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertNotNull;
12
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;
19
20 public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite {
21
22     private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node(
23             TopLevelList.QNAME);
24
25     @Override
26     protected void customizeTask(final DatastoreTestTask task) {
27         task.changeListener(TOP_LEVEL_LIST_ALL, DataChangeScope.ONE);
28     }
29
30     @Override
31     public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
32
33         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
34
35         assertNotNull(change);
36
37         assertNotContains(change.getCreatedData(), TOP_LEVEL);
38         assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR));
39
40         assertEmpty(change.getUpdatedData());
41         assertEmpty(change.getRemovedPaths());
42
43     }
44
45     @Override
46     public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
47             ExecutionException {
48
49         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
50         assertNotNull(change);
51
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));
56
57     }
58
59     @Override
60     protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
61             ExecutionException {
62
63         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
64         assertNotNull(change);
65         assertFalse(change.getCreatedData().isEmpty());
66
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());
71
72     }
73
74     @Override
75     protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
76             ExecutionException {
77
78         /*
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.
84          *
85          */
86         task.verifyNoChangeEvent();
87     }
88
89     @Override
90     public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
91             ExecutionException {
92
93         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
94
95         assertEmpty(change.getCreatedData());
96         assertEmpty(change.getUpdatedData());
97
98         assertNotContains(change.getUpdatedData(), TOP_LEVEL);
99         assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR));
100     }
101
102     @Override
103     protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
104         /*
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.
110          *
111          */
112         task.verifyNoChangeEvent();
113     }
114
115     @Override
116     protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
117         /*
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.
123          *
124          */
125         task.verifyNoChangeEvent();
126     }
127
128     @Override
129     protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
130         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
131
132         assertContains(change.getCreatedData(), path(FOO_SIBLING));
133         assertNotContains(change.getUpdatedData(),path(FOO), TOP_LEVEL);
134         assertEmpty(change.getRemovedPaths());
135     }
136 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.