Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / config / yang-jmx-generator / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / RuntimeRegistratorTest.java
index 6dd6444..8228eb6 100644 (file)
@@ -11,57 +11,52 @@ import static org.apache.commons.lang3.StringUtils.capitalize;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
+import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Collections;
 import java.util.List;
-
 import org.junit.Test;
-import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-
-import com.google.common.base.Optional;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 
 public class RuntimeRegistratorTest {
     // TODO add more tests
-    protected RuntimeBeanEntry prepareRootRB(List<RuntimeBeanEntry> children) {
+    protected RuntimeBeanEntry prepareRootRB(final List<RuntimeBeanEntry> children) {
 
-        DataSchemaNode dataSchemaNodeForReporting = mock(DataSchemaNode.class);
-        doReturn("DataSchemaNode").when(dataSchemaNodeForReporting).toString();
-        return new RuntimeBeanEntry("pa.cka.ge", dataSchemaNodeForReporting,
-                "module-name", "ModuleName", true, Optional.<String> absent(),
-                Collections.<AttributeIfc> emptyList(), children,
-                Collections.<Rpc> emptySet());
+        final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
+        doReturn("DataSchemaNode").when(nodeContainer).toString();
+        return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
+                "module-name", "ModuleName", true, Optional.absent(),
+                Collections.emptyList(), children, Collections.emptySet());
     }
 
-    protected RuntimeBeanEntry prepareChildRB(List<RuntimeBeanEntry> children,
-            String prefix) {
-        DataSchemaNode dataSchemaNodeForReporting = mock(DataSchemaNode.class);
-        doReturn("DataSchemaNode").when(dataSchemaNodeForReporting).toString();
-        return new RuntimeBeanEntry("pa.cka.ge", dataSchemaNodeForReporting,
+    protected RuntimeBeanEntry prepareChildRB(final List<RuntimeBeanEntry> children,
+            final String prefix) {
+        final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
+        doReturn("DataSchemaNode").when(nodeContainer).toString();
+        return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
                 prefix + "child-name", capitalize(prefix) + "ChildName", false,
-                Optional.<String> absent(),
-                Collections.<AttributeIfc> emptyList(), children,
-                Collections.<Rpc> emptySet());
+                Optional.absent(), Collections.emptyList(), children, Collections.emptySet());
     }
 
     @Test
     public void testHierarchy() {
-        LeafSchemaNode leaf = mock(LeafSchemaNode.class);
-        doReturn(new QName(URI.create("urn:x"), "leaf-local-name")).when(leaf)
-                .getQName();
+        final LeafSchemaNode leaf = mock(LeafSchemaNode.class);
+        doReturn(QName.create(URI.create("urn:x"), "leaf-local-name")).when(leaf).getQName();
         doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
-        doReturn(null).when(leaf).getDefault();
-        doReturn(null).when(leaf).getDescription();
+        doReturn(java.util.Optional.empty()).when(leaf).getDescription();
+
+        final StringTypeDefinition leafType = mock(StringTypeDefinition.class);
+        doReturn(java.util.Optional.empty()).when(leafType).getDefaultValue();
+        doReturn(leafType).when(leaf).getType();
 
-        TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
-        Type mockedType = mock(Type.class);
+        final TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
+        final Type mockedType = mock(Type.class);
         doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
         doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();
-
     }
 
 }

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