Adjust for Binding RPC codegen changes
[controller.git] / opendaylight / md-sal / sal-inmemory-datastore / src / test / java / org / opendaylight / controller / md / sal / dom / store / impl / WildcardedScopeSubtreeTest.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 import static org.junit.Assert.assertTrue;
13
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 WildcardedScopeSubtreeTest 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.SUBTREE);
28     }
29
30     @Override
31     public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception {
32
33         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
34
35         assertNotContains(change.getCreatedData(), TOP_LEVEL);
36         assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR));
37         assertEmpty(change.getUpdatedData());
38         assertEmpty(change.getRemovedPaths());
39
40     }
41
42     @Override
43     public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception {
44
45         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
46         assertNotNull(change);
47
48         assertContains(change.getCreatedData(), path(FOO, BAZ));
49         assertContains(change.getUpdatedData(), path(FOO));
50         assertNotContains(change.getUpdatedData(), TOP_LEVEL);
51         assertContains(change.getRemovedPaths(), path(FOO, BAR));
52
53     }
54
55     @Override
56     protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception {
57
58         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
59         assertNotNull(change);
60         assertFalse(change.getCreatedData().isEmpty());
61
62         assertContains(change.getCreatedData(), path(FOO), path(FOO, BAR), path(FOO, BAZ));
63         assertNotContains(change.getCreatedData(), TOP_LEVEL);
64         assertEmpty(change.getUpdatedData());
65         assertEmpty(change.getRemovedPaths());
66
67     }
68
69     @Override
70     protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception {
71
72         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
73         assertNotNull(change);
74         assertTrue(change.getCreatedData().isEmpty());
75         assertContains(change.getUpdatedData(), path(FOO));
76         assertNotContains(change.getUpdatedData(), TOP_LEVEL);
77         assertContains(change.getRemovedPaths(),path(FOO, BAZ));
78     }
79
80     @Override
81     public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception {
82
83         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
84
85         assertEmpty(change.getCreatedData());
86         assertEmpty(change.getUpdatedData());
87
88         assertNotContains(change.getUpdatedData(), TOP_LEVEL);
89         assertContains(change.getRemovedPaths(), path(FOO),path(FOO, BAZ),path(FOO,BAR));
90     }
91
92     @Override
93     protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception {
94         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
95
96         assertContains(change.getCreatedData(), path(FOO,BAZ));
97         assertNotContains(change.getCreatedData(), path(FOO,BAR));
98         assertContains(change.getUpdatedData(), path(FOO));
99         assertNotContains(change.getUpdatedData(), TOP_LEVEL);
100         assertEmpty(change.getRemovedPaths());
101     }
102
103     @Override
104     protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception {
105         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
106
107         assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ));
108         assertContains(change.getUpdatedData(), path(FOO));
109         assertNotContains(change.getUpdatedData(), TOP_LEVEL, path(FOO,BAR));
110         assertEmpty(change.getRemovedPaths());
111     }
112
113     @Override
114     protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception {
115         AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
116
117         assertContains(change.getCreatedData(), path(FOO_SIBLING));
118         assertNotContains(change.getUpdatedData(), path(FOO), TOP_LEVEL);
119         assertEmpty(change.getRemovedPaths());
120     }
121 }

©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.