2 * Copyright (c) 2013 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.controller.config.yangjmxgenerator;
10 import static org.apache.commons.lang3.StringUtils.capitalize;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.mock;
14 import com.google.common.base.Optional;
16 import java.util.Collections;
17 import java.util.List;
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.DataNodeContainer;
24 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
26 public class RuntimeRegistratorTest {
27 // TODO add more tests
28 protected RuntimeBeanEntry prepareRootRB(List<RuntimeBeanEntry> children) {
30 DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
31 doReturn("DataSchemaNode").when(nodeContainer).toString();
32 return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
33 "module-name", "ModuleName", true, Optional.<String> absent(),
34 Collections.<AttributeIfc> emptyList(), children,
35 Collections.<Rpc> emptySet());
38 protected RuntimeBeanEntry prepareChildRB(List<RuntimeBeanEntry> children,
40 DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
41 doReturn("DataSchemaNode").when(nodeContainer).toString();
42 return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
43 prefix + "child-name", capitalize(prefix) + "ChildName", false,
44 Optional.<String> absent(),
45 Collections.<AttributeIfc> emptyList(), children,
46 Collections.<Rpc> emptySet());
50 public void testHierarchy() {
51 LeafSchemaNode leaf = mock(LeafSchemaNode.class);
52 doReturn(new QName(URI.create("urn:x"), "leaf-local-name")).when(leaf)
54 doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
55 doReturn(null).when(leaf).getDefault();
56 doReturn(null).when(leaf).getDescription();
58 TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
59 Type mockedType = mock(Type.class);
60 doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
61 doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();