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