Convert anyxml nodes lazily
[netconf.git] / netconf / sal-netconf-connector / src / test / java / org / opendaylight / netconf / sal / connect / netconf / util / NodeContainerProxyTest.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.netconf.sal.connect.netconf.util;
10
11 import java.util.HashMap;
12 import java.util.HashSet;
13 import java.util.Map;
14 import java.util.Set;
15 import org.junit.Assert;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.netconf.util.NodeContainerProxy;
21 import org.opendaylight.yangtools.yang.common.QName;
22 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
24
25 public class NodeContainerProxyTest {
26
27     private static final QName QNAME = QName.create("ns", "2016-10-19", "name");
28     private static final QName NODE_1_QNAME = QName.create(QNAME, "node-1");
29     private static final QName NODE_2_QNAME = QName.create(QNAME, "node-2");
30     @Mock
31     private AugmentationSchemaNode augSchema1;
32     @Mock
33     private AugmentationSchemaNode augSchema2;
34     @Mock
35     private DataSchemaNode schemaNode1;
36     @Mock
37     private DataSchemaNode schemaNode2;
38     private NodeContainerProxy proxy;
39
40     @Before
41     public void setUp() throws Exception {
42         MockitoAnnotations.initMocks(this);
43         final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
44         childNodes.put(NODE_1_QNAME, schemaNode1);
45         childNodes.put(NODE_2_QNAME, schemaNode2);
46         final Set<AugmentationSchemaNode> augmentations = new HashSet<>();
47         augmentations.add(augSchema1);
48         augmentations.add(augSchema2);
49         proxy = new NodeContainerProxy(QNAME, childNodes, augmentations);
50     }
51
52     @Test
53     public void testGetQName() throws Exception {
54         Assert.assertEquals(QNAME, proxy.getQName());
55     }
56
57     @Test
58     public void testGetChildNodes() throws Exception {
59         Assert.assertEquals(2, proxy.getChildNodes().size());
60     }
61
62     @Test
63     public void testGetAvailableAugmentations() throws Exception {
64         final Set<AugmentationSchemaNode> augmentations = proxy.getAvailableAugmentations();
65         Assert.assertEquals(2, augmentations.size());
66         Assert.assertTrue(augmentations.contains(augSchema1));
67         Assert.assertTrue(augmentations.contains(augSchema2));
68     }
69
70     @Test
71     public void testGetDataChildByName() throws Exception {
72         final DataSchemaNode schemaNode = proxy.getDataChildByName(NODE_1_QNAME);
73         Assert.assertEquals(schemaNode1, schemaNode);
74     }
75
76     @Test
77     public void testGetTypeDefinitions() throws Exception {
78         Assert.assertTrue(proxy.getTypeDefinitions().isEmpty());
79     }
80
81     @Test
82     public void testGetGroupings() throws Exception {
83         Assert.assertTrue(proxy.getGroupings().isEmpty());
84     }
85
86     @Test
87     public void testGetUses() throws Exception {
88         Assert.assertTrue(proxy.getUses().isEmpty());
89     }
90
91     @Test
92     public void testGetUnknownSchemaNodes() throws Exception {
93         Assert.assertTrue(proxy.getUnknownSchemaNodes().isEmpty());
94     }
95
96     @Test(expected = UnsupportedOperationException.class)
97     public void testIsPresenceContainer() throws Exception {
98         proxy.isPresenceContainer();
99     }
100
101     @Test(expected = UnsupportedOperationException.class)
102     public void testIsAugmenting() throws Exception {
103         proxy.isAugmenting();
104     }
105
106     @Test(expected = UnsupportedOperationException.class)
107     public void testIsAddedByUses() throws Exception {
108         proxy.isAddedByUses();
109     }
110
111     @Test(expected = UnsupportedOperationException.class)
112     public void testIsConfiguration() throws Exception {
113         proxy.isConfiguration();
114     }
115
116     @Test(expected = UnsupportedOperationException.class)
117     public void testGetPath() throws Exception {
118         proxy.getPath();
119     }
120
121     @Test(expected = UnsupportedOperationException.class)
122     public void testGetDescription() throws Exception {
123         proxy.getDescription();
124     }
125
126     @Test(expected = UnsupportedOperationException.class)
127     public void testGetReference() throws Exception {
128         proxy.getReference();
129     }
130
131     @Test(expected = UnsupportedOperationException.class)
132     public void testGetStatus() throws Exception {
133         proxy.getStatus();
134     }
135
136 }