Adjust to yangtools-2.0.0 changes
[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 com.google.common.base.Optional;
15 import java.net.URI;
16 import java.util.Collections;
17 import java.util.List;
18 import org.junit.Test;
19 import org.opendaylight.mdsal.binding.model.api.Type;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
22 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
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.absent(),
33                 Collections.emptyList(), children, Collections.emptySet());
34     }
35
36     protected RuntimeBeanEntry prepareChildRB(final List<RuntimeBeanEntry> children,
37             final String prefix) {
38         final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
39         doReturn("DataSchemaNode").when(nodeContainer).toString();
40         return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
41                 prefix + "child-name", capitalize(prefix) + "ChildName", false,
42                 Optional.absent(), Collections.emptyList(), children, Collections.emptySet());
43     }
44
45     @Test
46     public void testHierarchy() {
47         final LeafSchemaNode leaf = mock(LeafSchemaNode.class);
48         doReturn(QName.create(URI.create("urn:x"), "leaf-local-name")).when(leaf).getQName();
49         doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
50         doReturn(java.util.Optional.empty()).when(leaf).getDescription();
51
52         final StringTypeDefinition leafType = mock(StringTypeDefinition.class);
53         doReturn(java.util.Optional.empty()).when(leafType).getDefaultValue();
54         doReturn(leafType).when(leaf).getType();
55
56         final TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
57         final Type mockedType = mock(Type.class);
58         doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
59         doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();
60     }
61
62 }

©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.