HoneyNode Java 11 support for 121 devices
[transportpce.git] / tests / honeynode / 1.2.1 / honeynode-plugin-impl / src / test / java / io / fd / honeycomb / transportpce / device / test / DeviceOperToConfig.java
@@ -16,6 +16,7 @@
 package io.fd.honeycomb.transportpce.device.test;
 
 import io.fd.honeycomb.transportpce.device.tools.DefaultDeviceFactory;
+import io.fd.honeycomb.transportpce.device.tools.DefaultPmListFactory;
 import io.fd.honeycomb.transportpce.test.common.DataStoreContext;
 import io.fd.honeycomb.transportpce.test.common.DataStoreContextImpl;
 
@@ -31,6 +32,7 @@ import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.openroadm.device.container.OrgOpenroadmDevice;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev161014.CurrentPmlist;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,10 +43,11 @@ import org.slf4j.LoggerFactory;
  */
 public class DeviceOperToConfig {
     private static final Logger LOG = LoggerFactory.getLogger(DeviceOperToConfig.class);
-    private static final String DEVICE_OPER = "src/main/resources/honeycomb-minimal-resources/config/device/oper-ROADMA.xml";
+    private static final String DEVICE_OPER = "src/test/resources/oper-ROADMA.xml";
+    private static final String PM_LIST_OPER = "src/test/resources/oper-ROADMA-cpm.xml";
     private static final String CONFIG_XSL = "src/main/resources/honeycomb-minimal-resources/config/device/config.xsl";
     private static final String DEVICE_XSL = "src/main/resources/honeycomb-minimal-resources/config/device/OperToConfig.xsl";
-    private static final String NAMESPACE_TRIMER_XSL = "src/main/resources/honeycomb-minimal-resources/config/device/NamespaceTrimmer.xslt";
+
 
 
     /**
@@ -54,29 +57,18 @@ public class DeviceOperToConfig {
      */
     public static String operToConfig() {
         String result =null;
-        LOG.info("process to transform xml file ");
+        LOG.info("process to transform xml file {}",DEVICE_OPER);
         TransformerFactory factory = TransformerFactory.newInstance();
         Source xslt = new StreamSource(new File(DEVICE_XSL));
-        Transformer transformer;
-        Source text;
-        StringWriter tmpwriter = new StringWriter();
-        StringReader reader;
         try {
+            StringWriter tmpwriter = new StringWriter();
             LOG.info("transforming xml data to config device ...");
-            transformer = factory.newTransformer(xslt);
-            text = new StreamSource(new File(DEVICE_OPER));
+            Transformer transformer = factory.newTransformer(xslt);
+            Source text = new StreamSource(new File(DEVICE_OPER));
             transformer.transform(text, new StreamResult(tmpwriter));
-            LOG.info("removing namespace ...");
-            xslt = new StreamSource(new File(NAMESPACE_TRIMER_XSL));
-            transformer = factory.newTransformer(xslt);
-            reader = new StringReader(tmpwriter.toString());
-            StringWriter device_config = new StringWriter();
-            text = new StreamSource(reader);
-            transformer.transform(text, new StreamResult(device_config));
-            //LOG.info("xml transformed : {}\n", device_config.toString());
-            result = device_config.toString();
+            result = tmpwriter.toString();
         } catch (TransformerException e) {
-            LOG.error("Transformer failed ");
+            LOG.error("Transformer failed ", e);
         }
         return result;
     }
@@ -116,8 +108,21 @@ public class DeviceOperToConfig {
 
     }
 
+    public static void createPmListFromFile() throws NullPointerException {
+        CurrentPmlist result = null;
+        DataStoreContext dataStoreContextUtil = new DataStoreContextImpl();
+        DefaultPmListFactory defaultDeviceFactory = new DefaultPmListFactory();
+        result = defaultDeviceFactory.createDefaultPmList(dataStoreContextUtil,new File(PM_LIST_OPER));
+        if (result != null) {
+            LOG.info("result pm list size : {}", result.getCurrentPm().size());
+        } else {
+            LOG.error("failed !");
+        }
+
+    }
+
     public static void main(String[] args) {
-        String xml = DeviceOperToConfig.getDeviceFromXML(DeviceOperToConfig.operToConfig());
-        DeviceOperToConfig.createDeviceFromString(xml);
+        DeviceOperToConfig.createPmListFromFile();
+
     }
 }