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
8 package org.opendaylight.netconf.sal.connect.netconf.util;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
13 import java.util.Collection;
14 import java.util.HashMap;
15 import java.util.HashSet;
17 import java.util.Optional;
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;
29 @RunWith(MockitoJUnitRunner.StrictStubs.class)
30 public class NodeContainerProxyTest {
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");
36 private AugmentationSchemaNode augSchema1;
38 private AugmentationSchemaNode augSchema2;
40 private DataSchemaNode schemaNode1;
42 private DataSchemaNode schemaNode2;
43 private NodeContainerProxy proxy;
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);
57 public void testGetQName() throws Exception {
58 assertEquals(QNAME, proxy.getQName());
62 public void testGetChildNodes() throws Exception {
63 assertEquals(2, proxy.getChildNodes().size());
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));
75 public void testFindDataChildByName() {
76 assertEquals(Optional.of(schemaNode1), proxy.findDataChildByName(NODE_1_QNAME));
80 public void testGetTypeDefinitions() throws Exception {
81 assertTrue(proxy.getTypeDefinitions().isEmpty());
85 public void testGetGroupings() throws Exception {
86 assertTrue(proxy.getGroupings().isEmpty());
90 public void testGetUses() throws Exception {
91 assertTrue(proxy.getUses().isEmpty());
95 public void testGetUnknownSchemaNodes() throws Exception {
96 assertTrue(proxy.getUnknownSchemaNodes().isEmpty());
99 @Test(expected = UnsupportedOperationException.class)
100 public void testIsPresenceContainer() throws Exception {
101 proxy.isPresenceContainer();
104 @Test(expected = UnsupportedOperationException.class)
105 public void testIsAugmenting() throws Exception {
106 proxy.isAugmenting();
109 @Test(expected = UnsupportedOperationException.class)
110 public void testIsAddedByUses() throws Exception {
111 proxy.isAddedByUses();
114 @Test(expected = UnsupportedOperationException.class)
115 public void testIsConfiguration() throws Exception {
116 proxy.isConfiguration();
119 @Test(expected = UnsupportedOperationException.class)
120 public void testGetPath() throws Exception {
124 @Test(expected = UnsupportedOperationException.class)
125 public void testGetDescription() throws Exception {
126 proxy.getDescription();
129 @Test(expected = UnsupportedOperationException.class)
130 public void testGetReference() throws Exception {
131 proxy.getReference();
134 @Test(expected = UnsupportedOperationException.class)
135 public void testGetStatus() throws Exception {