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;
15 import java.util.Collections;
16 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.DataSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
26 import com.google.common.base.Optional;
28 public class RuntimeRegistratorTest {
29 // TODO add more tests
30 protected RuntimeBeanEntry prepareRootRB(List<RuntimeBeanEntry> children) {
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());
40 protected RuntimeBeanEntry prepareChildRB(List<RuntimeBeanEntry> children,
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());
52 public void testHierarchy() {
53 LeafSchemaNode leaf = mock(LeafSchemaNode.class);
54 doReturn(new QName(URI.create("urn:x"), "leaf-local-name")).when(leaf)
56 doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
57 doReturn(null).when(leaf).getDefault();
58 doReturn(null).when(leaf).getDescription();
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();