b3b06151ebe9c243188a411409324bc31003b82b
[controller.git] / opendaylight / config / yang-jmx-generator / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / RuntimeRegistratorTest.java
1 /*
2  * Copyright (c) 2013 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.controller.config.yangjmxgenerator;
9
10 import static org.apache.commons.lang3.StringUtils.capitalize;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.mock;
13 import com.google.common.base.Optional;
14 import java.net.URI;
15 import java.util.Collections;
16 import java.util.List;
17 import org.junit.Test;
18 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
19 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
20 import org.opendaylight.mdsal.binding.model.api.Type;
21 import org.opendaylight.yangtools.yang.common.QName;
22 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
23 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
24
25 public class RuntimeRegistratorTest {
26     // TODO add more tests
27     protected RuntimeBeanEntry prepareRootRB(final List<RuntimeBeanEntry> children) {
28
29         final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
30         doReturn("DataSchemaNode").when(nodeContainer).toString();
31         return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
32                 "module-name", "ModuleName", true, Optional.<String> absent(),
33                 Collections.<AttributeIfc> emptyList(), children,
34                 Collections.<Rpc> emptySet());
35     }
36
37     protected RuntimeBeanEntry prepareChildRB(final List<RuntimeBeanEntry> children,
38             final String prefix) {
39         final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
40         doReturn("DataSchemaNode").when(nodeContainer).toString();
41         return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
42                 prefix + "child-name", capitalize(prefix) + "ChildName", false,
43                 Optional.<String> absent(),
44                 Collections.<AttributeIfc> emptyList(), children,
45                 Collections.<Rpc> emptySet());
46     }
47
48     @Test
49     public void testHierarchy() {
50         final LeafSchemaNode leaf = mock(LeafSchemaNode.class);
51         doReturn(new QName(URI.create("urn:x"), "leaf-local-name")).when(leaf)
52                 .getQName();
53         doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
54         doReturn(null).when(leaf).getDefault();
55         doReturn(null).when(leaf).getDescription();
56
57         final TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
58         final Type mockedType = mock(Type.class);
59         doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
60         doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();
61
62     }
63
64 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.