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.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
22 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
24 public class NodeContainerProxyTest {
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");
30 private AugmentationSchema augSchema1;
32 private AugmentationSchema augSchema2;
34 private DataSchemaNode schemaNode1;
36 private DataSchemaNode schemaNode2;
37 private NodeContainerProxy proxy;
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<AugmentationSchema> augmentations = new HashSet<>();
46 augmentations.add(augSchema1);
47 augmentations.add(augSchema2);
48 proxy = new NodeContainerProxy(QNAME, childNodes, augmentations);
52 public void testGetQName() throws Exception {
53 Assert.assertEquals(QNAME, proxy.getQName());
57 public void testGetChildNodes() throws Exception {
58 Assert.assertEquals(2, proxy.getChildNodes().size());
62 public void testGetAvailableAugmentations() throws Exception {
63 final Set<AugmentationSchema> augmentations = proxy.getAvailableAugmentations();
64 Assert.assertEquals(2, augmentations.size());
65 Assert.assertTrue(augmentations.contains(augSchema1));
66 Assert.assertTrue(augmentations.contains(augSchema2));
70 public void testGetDataChildByName() throws Exception {
71 final DataSchemaNode schemaNode = proxy.getDataChildByName(NODE_1_QNAME);
72 Assert.assertEquals(schemaNode1, schemaNode);
76 public void testGetTypeDefinitions() throws Exception {
77 Assert.assertTrue(proxy.getTypeDefinitions().isEmpty());
81 public void testGetGroupings() throws Exception {
82 Assert.assertTrue(proxy.getGroupings().isEmpty());
86 public void testGetUses() throws Exception {
87 Assert.assertTrue(proxy.getUses().isEmpty());
91 public void testGetUnknownSchemaNodes() throws Exception {
92 Assert.assertTrue(proxy.getUnknownSchemaNodes().isEmpty());
95 @Test(expected = UnsupportedOperationException.class)
96 public void testIsPresenceContainer() throws Exception {
97 proxy.isPresenceContainer();
100 @Test(expected = UnsupportedOperationException.class)
101 public void testIsAugmenting() throws Exception {
102 proxy.isAugmenting();
105 @Test(expected = UnsupportedOperationException.class)
106 public void testIsAddedByUses() throws Exception {
107 proxy.isAddedByUses();
110 @Test(expected = UnsupportedOperationException.class)
111 public void testIsConfiguration() throws Exception {
112 proxy.isConfiguration();
115 @Test(expected = UnsupportedOperationException.class)
116 public void testGetConstraints() throws Exception {
117 proxy.getConstraints();
120 @Test(expected = UnsupportedOperationException.class)
121 public void testGetPath() throws Exception {
125 @Test(expected = UnsupportedOperationException.class)
126 public void testGetDescription() throws Exception {
127 proxy.getDescription();
130 @Test(expected = UnsupportedOperationException.class)
131 public void testGetReference() throws Exception {
132 proxy.getReference();
135 @Test(expected = UnsupportedOperationException.class)
136 public void testGetStatus() throws Exception {