Fix for Microsemi Unit tests
Change-Id: I1e94c85d19de53f82eb7fc657fff42535dafd9f5
diff --git a/apps/yang/src/main/java/org/onosproject/yang/AbstractYangModelRegistrator.java b/apps/yang/src/main/java/org/onosproject/yang/AbstractYangModelRegistrator.java
index 6e3a691..a1c74c7 100644
--- a/apps/yang/src/main/java/org/onosproject/yang/AbstractYangModelRegistrator.java
+++ b/apps/yang/src/main/java/org/onosproject/yang/AbstractYangModelRegistrator.java
@@ -44,7 +44,7 @@
protected final Logger log = LoggerFactory.getLogger(getClass());
private final Class<?> loaderClass;
- private Map<YangModuleId, AppModuleInfo> appInfo;
+ protected Map<YangModuleId, AppModuleInfo> appInfo;
protected YangModel model;
private ModelRegistrationParam registrationParam;
diff --git a/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/yang/impl/IetfSystemManager.java b/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/yang/impl/IetfSystemManager.java
index 9a8b471..0411967 100644
--- a/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/yang/impl/IetfSystemManager.java
+++ b/drivers/microsemi/src/main/java/org/onosproject/drivers/microsemi/yang/impl/IetfSystemManager.java
@@ -156,10 +156,9 @@
rpc.append("xmlns:sysms=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">");
rpc.append("<platform>");
rpc.append("<os-release/>");
-//FIXME: This has been commented out until the augment of common models issue with onos-yang-tools is sorted
-// rpc.append("<sysms:device-identification>");
-// rpc.append("<sysms:serial-number/>");
-// rpc.append("</sysms:device-identification>");
+ rpc.append("<sysms:device-identification>");
+ rpc.append("<sysms:serial-number/>");
+ rpc.append("</sysms:device-identification>");
rpc.append("</platform>");
rpc.append("<clock>");
rpc.append("<current-datetime/>");
diff --git a/drivers/microsemi/src/test/java/org/onosproject/yang/MockMicrosemiRegistrator.java b/drivers/microsemi/src/test/java/org/onosproject/yang/MockMicrosemiRegistrator.java
index 111ec8a..785ba8d 100644
--- a/drivers/microsemi/src/test/java/org/onosproject/yang/MockMicrosemiRegistrator.java
+++ b/drivers/microsemi/src/test/java/org/onosproject/yang/MockMicrosemiRegistrator.java
@@ -15,9 +15,12 @@
*/
package org.onosproject.yang;
+import com.google.common.collect.ImmutableMap;
import org.onosproject.models.microsemi.MicrosemiModelRegistrator;
import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.tool.YangNodeInfo;
+import org.onosproject.yang.model.YangModuleId;
+import org.onosproject.yang.runtime.AppModuleInfo;
import org.onosproject.yang.runtime.DefaultModelRegistrationParam;
import org.onosproject.yang.runtime.ModelRegistrationParam;
import org.onosproject.yang.runtime.YangModelRegistry;
@@ -26,7 +29,9 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import static org.junit.Assert.fail;
import static org.onosproject.yang.compiler.tool.YangCompilerManager.deSerializeDataModel;
@@ -66,6 +71,14 @@
}
}
+
+ public void addAppInfo(Map<YangModuleId, AppModuleInfo> map) {
+ Map<YangModuleId, AppModuleInfo> appInfoCopy = new HashMap<>();
+ appInfoCopy.putAll(appInfo);
+ appInfoCopy.putAll(map);
+ appInfo = ImmutableMap.copyOf(appInfoCopy);
+ }
+
public YangModelRegistry registry() {
return modelRegistry;
}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/yang/MockYangRegistrator.java b/drivers/microsemi/src/test/java/org/onosproject/yang/MockYangRegistrator.java
new file mode 100644
index 0000000..c564e9a
--- /dev/null
+++ b/drivers/microsemi/src/test/java/org/onosproject/yang/MockYangRegistrator.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yang;
+
+import org.onosproject.models.common.YangModelRegistrator;
+import org.onosproject.yang.model.YangModuleId;
+import org.onosproject.yang.runtime.AppModuleInfo;
+
+
+import java.util.Map;
+
+public class MockYangRegistrator extends YangModelRegistrator {
+ public Map<YangModuleId, AppModuleInfo> getAppInfo() {
+ return appInfo;
+ }
+}
diff --git a/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java b/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
index 747c790..bb931f0 100644
--- a/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
+++ b/drivers/microsemi/src/test/java/org/onosproject/yang/serializers/xml/MockYangSerializerContext.java
@@ -16,6 +16,7 @@
package org.onosproject.yang.serializers.xml;
import org.onosproject.yang.MockMicrosemiRegistrator;
+import org.onosproject.yang.MockYangRegistrator;
import org.onosproject.yang.model.SchemaContext;
import org.onosproject.yang.runtime.Annotation;
import org.onosproject.yang.runtime.DefaultAnnotation;
@@ -27,19 +28,22 @@
public class MockYangSerializerContext implements YangSerializerContext {
- private static MockMicrosemiRegistrator schemaProvider =
+ private static MockMicrosemiRegistrator schemaProviderMicrosemi =
new MockMicrosemiRegistrator();
+ private static MockYangRegistrator schemaProviderYang =
+ new MockYangRegistrator();
private static final String NETCONF_NS =
"urn:ietf:params:xml:ns:netconf:base:1.0";
private static final String XMNLS_NC = "xmlns:xc";
public MockYangSerializerContext() {
- schemaProvider.activate();
+ schemaProviderMicrosemi.addAppInfo(schemaProviderYang.getAppInfo());
+ schemaProviderMicrosemi.activate();
}
@Override
public SchemaContext getContext() {
- DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProvider.registry();
+ DefaultYangModelRegistry registry = (DefaultYangModelRegistry) schemaProviderMicrosemi.registry();
return registry;
}