Merge "Remove use of ThreadPools in sal-netconf-connector"
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / rpc / SimulatedCreateSubscription.java
index c6f7fac0db34e99026e3a9e2c9ec82c3d72b72cb..fc7e99a31d3cf0b72cb56b05e872a3b20f79b882 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.collect.Maps;
 import java.io.File;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -25,7 +26,6 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.netconf.api.DocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
@@ -46,7 +46,7 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
     public SimulatedCreateSubscription(final String id, final Optional<File> notificationsFile) {
         super(id);
 
-        Optional<Notifications> notifs;
+        final Optional<Notifications> notifs;
 
         if (notificationsFile.isPresent()) {
             notifs = Optional.of(loadNotifications(notificationsFile.get()));
@@ -56,9 +56,9 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
         }
 
         if (notifs.isPresent()) {
-            Map<Notification, NetconfMessage> preparedMessages = Maps.newHashMapWithExpectedSize(
-                notifs.get().getNotificationList().size());
-            for (final Notification notification : notifs.get().getNotificationList()) {
+            final Collection<Notification> toCopy = notifs.get().getNotificationList();
+            final Map<Notification, NetconfMessage> preparedMessages = Maps.newHashMapWithExpectedSize(toCopy.size());
+            for (final Notification notification : toCopy) {
                 final NetconfMessage parsedNotification = parseNetconfNotification(notification.getContent());
                 preparedMessages.put(notification, parsedNotification);
             }
@@ -66,7 +66,6 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
         } else {
             this.notifications = Collections.emptyMap();
         }
-
     }
 
     private static Notifications loadNotifications(final File file) {
@@ -90,8 +89,7 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
     }
 
     @Override
-    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
-            throws DocumentedException {
+    protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
         long delayAggregator = 0;
 
         for (final Map.Entry<Notification, NetconfMessage> notification : notifications.entrySet()) {
@@ -105,7 +103,7 @@ public class SimulatedCreateSubscription extends AbstractLastNetconfOperation im
                 }, delayAggregator, TimeUnit.SECONDS);
             }
         }
-        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
     }
 
     private static NetconfMessage parseNetconfNotification(String content) {