sal-binding-it: use lambdas 80/57180/3
authorStephen Kitt <skitt@redhat.com>
Tue, 16 May 2017 15:50:58 +0000 (17:50 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 17 May 2017 08:54:24 +0000 (08:54 +0000)
This series of patches uses lambdas instead of anonymous classes for
functional interfaces when possible. Lambdas are replaced with method
references when appropriate.

Change-Id: I714b8b5499f6fe5d6f2b2172b59bfba10678bae4
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/DataServiceIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/RoutedServiceIT.java

index 717aa638114c5fb3779af6b00bed1d7b12817e9a..fc92567ed5354475ed704f21968a53d694b0ae84 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertNull;
 import java.util.concurrent.Future;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
@@ -42,13 +41,7 @@ public class DataServiceIT extends AbstractIT {
      */
     @Test
     public void test() throws Exception {
-        BindingAwareConsumer consumer = new BindingAwareConsumer() {
-
-            @Override
-            public void onSessionInitialized(final ConsumerContext session) {
-                consumerDataService = session.getSALService(DataBrokerService.class);
-            }
-        };
+        BindingAwareConsumer consumer = session -> consumerDataService = session.getSALService(DataBrokerService.class);
 
         broker.registerConsumer(consumer);
 
index 1a950a10623c5e9b7a5a2c5cdcf02460233bac3d..db978dbeec8b8861441800713939bb0f6be3c531 100644 (file)
@@ -14,7 +14,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.Test;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
@@ -64,13 +63,10 @@ public class NotificationIT extends AbstractIT {
 
         LOG.info("The registration of the Consumer 1. It retrieves Notification Service "
                 + "from MD-SAL and registers OpendaylightTestNotificationListener as notification listener");
-        BindingAwareConsumer consumer1 = new BindingAwareConsumer() {
-            @Override
-            public void onSessionInitialized(ConsumerContext session) {
-                NotificationService notificationService = session.getSALService(NotificationService.class);
-                assertNotNull(notificationService);
-                listener1Reg = notificationService.registerNotificationListener(listener1);
-            }
+        BindingAwareConsumer consumer1 = session -> {
+            NotificationService notificationService = session.getSALService(NotificationService.class);
+            assertNotNull(notificationService);
+            listener1Reg = notificationService.registerNotificationListener(listener1);
         };
         // registerConsumer method calls onSessionInitialized method above
         broker.registerConsumer(consumer1);
@@ -93,14 +89,8 @@ public class NotificationIT extends AbstractIT {
 
         LOG.info("The registration of the Consumer 2. SalFlowListener is registered "
                 + "registered as notification listener.");
-        BindingAwareProvider provider = new BindingAwareProvider() {
-
-            @Override
-            public void onSessionInitiated(ProviderContext session) {
-                listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener(
-                        listener2);
-            }
-        };
+        BindingAwareProvider provider = session -> listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener(
+                listener2);
 
         // registerConsumer method calls onSessionInitialized method above
         broker.registerProvider(provider);
index 0b365cac49e7444b1ad280322b094f09e0b1613b..a394bcba89e0731dae13e92f00a5be549cf3d6c5 100644 (file)
@@ -17,7 +17,6 @@ import com.google.common.util.concurrent.Futures;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
@@ -96,12 +95,8 @@ public class RoutedServiceIT extends AbstractIT {
         assertSame(odlRoutedService2, secondReg.getInstance());
         assertNotSame(secondReg, firstReg);
 
-        final BindingAwareConsumer consumer = new BindingAwareConsumer() {
-            @Override
-            public void onSessionInitialized(final ConsumerContext session) {
-                consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class);
-            }
-        };
+        final BindingAwareConsumer consumer =
+                session -> consumerService = session.getRpcService(OpendaylightTestRoutedRpcService.class);
         LOG.info("Register routeService consumer");
         broker.registerConsumer(consumer);