2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.netconf.sal.connect.netconf.util;
11 import java.util.HashMap;
12 import java.util.HashSet;
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;
25 public class NodeContainerProxyTest {
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");
31 private AugmentationSchemaNode augSchema1;
33 private AugmentationSchemaNode augSchema2;
35 private DataSchemaNode schemaNode1;
37 private DataSchemaNode schemaNode2;
38 private NodeContainerProxy proxy;
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);
53 public void testGetQName() throws Exception {
54 Assert.assertEquals(QNAME, proxy.getQName());
58 public void testGetChildNodes() throws Exception {
59 Assert.assertEquals(2, proxy.getChildNodes().size());
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));
71 public void testGetDataChildByName() throws Exception {
72 final DataSchemaNode schemaNode = proxy.getDataChildByName(NODE_1_QNAME);
73 Assert.assertEquals(schemaNode1, schemaNode);
77 public void testGetTypeDefinitions() throws Exception {
78 Assert.assertTrue(proxy.getTypeDefinitions().isEmpty());
82 public void testGetGroupings() throws Exception {
83 Assert.assertTrue(proxy.getGroupings().isEmpty());
87 public void testGetUses() throws Exception {
88 Assert.assertTrue(proxy.getUses().isEmpty());
92 public void testGetUnknownSchemaNodes() throws Exception {
93 Assert.assertTrue(proxy.getUnknownSchemaNodes().isEmpty());
96 @Test(expected = UnsupportedOperationException.class)
97 public void testIsPresenceContainer() throws Exception {
98 proxy.isPresenceContainer();
101 @Test(expected = UnsupportedOperationException.class)
102 public void testIsAugmenting() throws Exception {
103 proxy.isAugmenting();
106 @Test(expected = UnsupportedOperationException.class)
107 public void testIsAddedByUses() throws Exception {
108 proxy.isAddedByUses();
111 @Test(expected = UnsupportedOperationException.class)
112 public void testIsConfiguration() throws Exception {
113 proxy.isConfiguration();
116 @Test(expected = UnsupportedOperationException.class)
117 public void testGetPath() throws Exception {
121 @Test(expected = UnsupportedOperationException.class)
122 public void testGetDescription() throws Exception {
123 proxy.getDescription();
126 @Test(expected = UnsupportedOperationException.class)
127 public void testGetReference() throws Exception {
128 proxy.getReference();
131 @Test(expected = UnsupportedOperationException.class)
132 public void testGetStatus() throws Exception {