Fix warnings in notification-supplier 74/94374/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 3 Jan 2021 17:26:30 +0000 (18:26 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 3 Jan 2021 18:01:02 +0000 (19:01 +0100)
There are a few places using deprecated constructs, update them.

Change-Id: Iee4ddb62f37f2d548bb3b2b2b6f2e88e92dd738e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImpl.java
applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImpl.java
applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestSupplierVerifyHelper.java

index 91b291d3c3551e1536ab241453c432327ae56ed2..b247ce1b143421e1e49b372fc974091b29f2cde5 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import java.util.Collections;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
@@ -52,19 +53,18 @@ public class FlowStatNotificationSupplierImpl extends AbstractNotificationSuppli
     @Override
     public FlowsStatisticsUpdate createNotification(final FlowStatistics flowStatistics,
                                                     final InstanceIdentifier<FlowStatistics> path) {
-        Preconditions.checkArgument(flowStatistics != null);
-        Preconditions.checkArgument(path != null);
-
-        final FlowAndStatisticsMapListBuilder fsmlBuilder = new FlowAndStatisticsMapListBuilder(flowStatistics);
-        fsmlBuilder.setFlowId(new FlowId(path.firstKeyOf(Flow.class).getId().getValue()));
+        checkArgument(flowStatistics != null);
+        checkArgument(path != null);
 
-        final FlowsStatisticsUpdateBuilder builder = new FlowsStatisticsUpdateBuilder();
-        builder.setId(getNodeId(path));
-        builder.setMoreReplies(Boolean.FALSE);
-        // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
-        builder.setNodeConnector(Collections.emptyList());
-        builder.setFlowAndStatisticsMapList(Collections.singletonList(fsmlBuilder.build()));
-        return builder.build();
+        return new FlowsStatisticsUpdateBuilder()
+            .setId(getNodeId(path))
+            .setMoreReplies(Boolean.FALSE)
+            // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
+            .setNodeConnector(Collections.emptyMap())
+            .setFlowAndStatisticsMapList(Collections.singletonList(new FlowAndStatisticsMapListBuilder(flowStatistics)
+                .setFlowId(new FlowId(path.firstKeyOf(Flow.class).getId().getValue()))
+                .build()))
+            .build();
     }
 }
 
index a15f00e6abfe432772ec856906e8fa45ae54dff7..2a34f49b74c4d20b4b40f4a1e5e73f8dfc6ce827 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.stat;
 
-import com.google.common.base.Preconditions;
-import java.util.Collections;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -21,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.statistics.FlowTableStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
 
 /**
  * Implementation define a contract between {@link FlowTableStatistics} data object
@@ -52,20 +53,18 @@ public class FlowTableStatNotificationSupplierImpl extends
     @Override
     public FlowTableStatisticsUpdate createNotification(final FlowTableStatistics flowTableStatistics,
                                                         final InstanceIdentifier<FlowTableStatistics> path) {
-        Preconditions.checkArgument(flowTableStatistics != null);
-        Preconditions.checkArgument(path != null);
-
-        final FlowTableAndStatisticsMapBuilder ftsmBuilder = new FlowTableAndStatisticsMapBuilder(flowTableStatistics);
-        ftsmBuilder.withKey(new FlowTableAndStatisticsMapKey(
-                new TableId(path.firstKeyOf(Table.class).getId())));
+        checkArgument(flowTableStatistics != null);
+        checkArgument(path != null);
 
-        final FlowTableStatisticsUpdateBuilder builder = new FlowTableStatisticsUpdateBuilder();
-        builder.setId(getNodeId(path));
-        builder.setMoreReplies(Boolean.FALSE);
-        // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
-        builder.setNodeConnector(Collections.emptyList());
-        builder.setFlowTableAndStatisticsMap(Collections.singletonList(ftsmBuilder.build()));
-        return builder.build();
+        return new FlowTableStatisticsUpdateBuilder()
+            .setId(getNodeId(path))
+            .setMoreReplies(Boolean.FALSE)
+            // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
+            .setNodeConnector(BindingMap.of())
+            .setFlowTableAndStatisticsMap(BindingMap.of(new FlowTableAndStatisticsMapBuilder(flowTableStatistics)
+                .withKey(new FlowTableAndStatisticsMapKey(new TableId(path.firstKeyOf(Table.class).getId())))
+                .build()))
+            .build();
     }
 }
 
index 627d43127d0098e5eb1ce6e9a1e4a327dce081ee..c3d134a63155f77230b0cb35b63d5213f3e00f9b 100644 (file)
@@ -7,22 +7,17 @@
  */
 package org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper;
 
-import org.mockito.ArgumentMatchers;
-import org.mockito.Mockito;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
+
 import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
 
 public final class TestSupplierVerifyHelper {
-
     private TestSupplierVerifyHelper() {
-        throw new UnsupportedOperationException("Test utility class");
+        // Hidden on purpose
     }
 
-    public static void verifyDataTreeChangeListenerRegistration(DataBroker dataBroker) {
-
-        Mockito.verify(dataBroker).registerDataTreeChangeListener(
-                ArgumentMatchers.<DataTreeIdentifier>any(),
-                ArgumentMatchers.<DataTreeChangeListener>any());
+    public static void verifyDataTreeChangeListenerRegistration(final DataBroker dataBroker) {
+        verify(dataBroker).registerDataTreeChangeListener(any(), any());
     }
 }