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