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