Integrate netconf-mapping-api into netconf-server
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / rpc / SimulatedGetConfig.java
index 572fd961b742b1e9b90228651821aa749c37d05a..83dc1006013c42bb241ec764798c1419708ee4d3 100644 (file)
@@ -5,18 +5,16 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.test.tool.rpc;
 
-import com.google.common.base.Optional;
 import java.io.File;
 import java.io.IOException;
 import java.util.List;
-import org.opendaylight.netconf.api.DocumentedException;
+import java.util.Optional;
 import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.util.mapping.AbstractLastNetconfOperation;
+import org.opendaylight.netconf.server.api.operations.AbstractLastNetconfOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -24,19 +22,18 @@ import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
 public class SimulatedGetConfig extends AbstractLastNetconfOperation {
+    private static final Logger LOG = LoggerFactory.getLogger(SimulatedGetConfig.class);
 
     private final DataList storage;
-    private static final Logger LOG = LoggerFactory
-            .getLogger(SimulatedGetConfig.class);
 
     public SimulatedGetConfig(final String netconfSessionIdForReporting, final DataList storage,
                               final Optional<File> initialConfigXMLFile) {
         super(netconfSessionIdForReporting);
 
         if (initialConfigXMLFile.isPresent()) {
-            LOG.info("File is present: {}", initialConfigXMLFile.get()
-                    .getName());
-            this.storage = loadInitialConfigXMLFile(initialConfigXMLFile.get());
+            final var file = initialConfigXMLFile.orElseThrow();
+            LOG.info("File is present: {}", file.getName());
+            this.storage = loadInitialConfigXMLFile(file);
         } else {
             this.storage = storage;
         }
@@ -60,9 +57,8 @@ public class SimulatedGetConfig extends AbstractLastNetconfOperation {
     }
 
     @Override
-    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
-            throws DocumentedException {
-        final Element element = XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
+    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
+        final Element element = document.createElement(XmlNetconfConstants.DATA_KEY);
 
         for (final XmlElement e : storage.getConfigList()) {
             final Element domElement = e.getDomElement();