Bug 8055: use lambdas instead of anonymous classes 15/53015/6
authorStephen Kitt <skitt@redhat.com>
Wed, 8 Mar 2017 16:03:45 +0000 (17:03 +0100)
committerStephen Kitt <skitt@redhat.com>
Thu, 23 Mar 2017 12:57:26 +0000 (13:57 +0100)
Change-Id: I72b437b9e225f022fa3c55492f6b0f9751450dea
Signed-off-by: Stephen Kitt <skitt@redhat.com>
22 files changed:
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/reconciliation/ReconciliationManager.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/reconciliation/configuration/GlobalConfigOperationalChangeGetter.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueue.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/FutureTransformUtils.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbClientImpl.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/StalePassiveConnectionService.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtils.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/ReconciliationManager.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/InstanceIdentifierCodecTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundMapperTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundUtilTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolRemovedCommandTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommandTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/BridgeConfigReconciliationTaskTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommandTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommandTest.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommandTest.java

index a371b8bc2172d857704e61317f712cbfe22dcf22..8312526e331e781a85d875ce734efa05cb596003 100644 (file)
@@ -15,7 +15,6 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
@@ -32,7 +31,6 @@ import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration.Hwvt
 import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.connection.ConnectionReconciliationTask;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.HwvtepGlobalRemoveCommand;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionCommand;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
@@ -546,12 +544,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
                 (InstanceIdentifier<Node>) HwvtepSouthboundUtil
                         .getInstanceIdentifierCodec().bindingDeserializer(entity.getId());
 
-        txInvoker.invoke(new TransactionCommand() {
-            @Override
-            public void execute(ReadWriteTransaction transaction) {
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
-            }
-        });
+        txInvoker.invoke(transaction -> transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid));
     }
 
     private HwvtepConnectionInstance getConnectionInstanceFromEntity(Entity entity) {
index d217ebc034a9a7edfca6556358c360f7a15bda80..4817cbd922b0685fb095138bd36b174ba6edb9d4 100644 (file)
@@ -244,12 +244,7 @@ public class HwvtepDeviceInfo {
     }
 
     public void scheduleTransaction(final TransactCommand transactCommand) {
-        dependencyQueue.submit(new Runnable() {
-            @Override
-            public void run() {
-                connectionInstance.transact(transactCommand);
-            }
-        });
+        dependencyQueue.submit(() -> connectionInstance.transact(transactCommand));
     }
 
     public void clearInTransitData() {
index 397dd630e40b66884e1ecf4fb95fe1cdfdf50284..3d6374f9de97213783dcc961330f253e7efc906b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ * Copyright © 2016, 2017 Brocade Communications Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -75,12 +75,7 @@ public class ReconciliationManager implements AutoCloseable {
     public void enqueueForRetry(final ReconciliationTask task) {
         LOG.trace("Reconciliation task re-queued for re-execution {}",task);
         reconTaskManager.cacheTask(task, taskTriager.schedule(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        task.checkReadinessAndProcess();
-                    }
-                }, task.retryDelayInMills(), TimeUnit.MILLISECONDS
+                () -> task.checkReadinessAndProcess(), task.retryDelayInMills(), TimeUnit.MILLISECONDS
             )
         );
     }
index 534f7e892fada20bff870b3784deb24ef5eacd08..4633d634ebcb08904f49c9f5c7f10afae19db978 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
@@ -67,17 +66,9 @@ public class GlobalConfigOperationalChangeGetter {
             return null;
         }
         Iterable<LocalUcastMacs> removedLocalUcastMacs = Iterables.filter(localUcastMacs,
-                new Predicate<LocalUcastMacs>() {
-                    @Override
-                    public boolean apply(LocalUcastMacs mac) {
-                        String ls = mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
-                                getHwvtepNodeName().getValue();
-                        if (removedSwitchNames.contains(ls)) {
-                            return true;
-                        }
-                        return false;
-                    }
-                });
+                mac -> removedSwitchNames.contains(
+                        mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
+                                getHwvtepNodeName().getValue()));
         return Lists.newArrayList(removedLocalUcastMacs);
     }
 
@@ -91,17 +82,9 @@ public class GlobalConfigOperationalChangeGetter {
             return null;
         }
         Iterable<LocalMcastMacs> removedLocalMcastMacs = Iterables.filter(localMcastMacs,
-                new Predicate<LocalMcastMacs>() {
-                    @Override
-                    public boolean apply(LocalMcastMacs mac) {
-                        String ls = mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
-                                getHwvtepNodeName().getValue();
-                        if (removedSwitchNames.contains(ls)) {
-                            return true;
-                        }
-                        return false;
-                    }
-                });
+                mac -> removedSwitchNames.contains(
+                        mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
+                                getHwvtepNodeName().getValue()));
         return Lists.newArrayList(removedLocalMcastMacs);
     }
 
index c6892649da15fab0e4c30053ff3a3680b23696bf..65af6be9ead37d85c4edf18176729371dfbf3a00 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright © 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -83,30 +83,25 @@ public class DependencyQueue {
                                   LinkedBlockingQueue<DependentJob> queue) {
         final List<DependentJob> readyJobs =  getReadyJobs(queue);
         if (readyJobs.size() > 0) {
-            executorService.submit(new Runnable() {
+            executorService.submit(() -> hwvtepConnectionInstance.transact(new TransactCommand() {
                 @Override
-                public void run() {
-                    hwvtepConnectionInstance.transact(new TransactCommand() {
-                        @Override
-                        public void execute(TransactionBuilder transactionBuilder) {
-                            HwvtepOperationalState operationalState = new HwvtepOperationalState(hwvtepConnectionInstance);
-                            for (DependentJob job : readyJobs) {
-                                job.onDependencyResolved(operationalState, transactionBuilder);
-                            }
-                        }
-
-                        @Override
-                        public void onConfigUpdate(TransactionBuilder transaction, InstanceIdentifier nodeIid,
-                                                   Identifiable data, InstanceIdentifier key, Object... extraData) {
-                        }
-
-                        @Override
-                        public void doDeviceTransaction(TransactionBuilder transaction, InstanceIdentifier nodeIid,
-                                                        Identifiable data, InstanceIdentifier key, Object... extraData) {
-                        }
-                    });
+                public void execute(TransactionBuilder transactionBuilder) {
+                    HwvtepOperationalState operationalState = new HwvtepOperationalState(hwvtepConnectionInstance);
+                    for (DependentJob job : readyJobs) {
+                        job.onDependencyResolved(operationalState, transactionBuilder);
+                    }
                 }
-            });
+
+                @Override
+                public void onConfigUpdate(TransactionBuilder transaction, InstanceIdentifier nodeIid,
+                                           Identifiable data, InstanceIdentifier key, Object... extraData) {
+                }
+
+                @Override
+                public void doDeviceTransaction(TransactionBuilder transaction, InstanceIdentifier nodeIid,
+                                                Identifiable data, InstanceIdentifier key, Object... extraData) {
+                }
+            }));
         }
     }
 
index 374421e517dfce6e1e12c2f5c3f055ecb522e800..e81ddb4a97a2d40efeb0ce6ad8cb3e9454061d63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 EBay Software Foundation and others. All rights reserved.
+ * Copyright © 2014, 2017 EBay Software Foundation and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -28,9 +28,8 @@ public class FutureTransformUtils {
     public static final ListenableFuture<List<OperationResult>> transformTransactResponse(
             ListenableFuture<List<JsonNode>> transactResponseFuture, final List<Operation> operations) {
         OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-        return Futures.transform(transactResponseFuture, new Function<List<JsonNode>, List<OperationResult>>() {
-            @Override
-            public List<OperationResult> apply(List<JsonNode> jsonNodes) {
+        return Futures.transform(transactResponseFuture,
+            (Function<List<JsonNode>, List<OperationResult>>) jsonNodes -> {
                 final List<OperationResult> operationResults = new ArrayList<>();
                 for (int index = 0; index < jsonNodes.size(); index++) {
                     JsonNode jsonNode = jsonNodes.get(index);
@@ -72,7 +71,6 @@ public class FutureTransformUtils {
                 }
 
                 return operationResults;
-            }
-        });
+            });
     }
 }
index 3b6045f409aab2e0be0f78443d641280268910d5..c660caec5b7c952fbfc77edf9f8f7d961648aa50 100644 (file)
@@ -37,7 +37,6 @@ import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo.ConnectionType;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo.SocketConnectionType;
 import org.opendaylight.ovsdb.lib.error.ParsingException;
-import org.opendaylight.ovsdb.lib.jsonrpc.Params;
 import org.opendaylight.ovsdb.lib.message.MonitorRequest;
 import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
 import org.opendaylight.ovsdb.lib.message.TableUpdate;
@@ -186,22 +185,13 @@ public class OvsdbClientImpl implements OvsdbClient {
                                                             final MonitorCallBack callback) {
 
         final ImmutableMap<String, MonitorRequest> reqMap = Maps.uniqueIndex(monitorRequest,
-                new Function<MonitorRequest, String>() {
-                    @Override
-                    public String apply(MonitorRequest input) {
-                        return input.getTableName();
-                    }
-                });
+            input -> input.getTableName());
 
         final MonitorHandle monitorHandle = new MonitorHandle(UUID.randomUUID().toString());
         registerCallback(monitorHandle, callback, dbSchema);
 
-        ListenableFuture<JsonNode> monitor = rpc.monitor(new Params() {
-            @Override
-            public List<Object> params() {
-                return Lists.<Object>newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap);
-            }
-        });
+        ListenableFuture<JsonNode> monitor = rpc.monitor(
+            () -> Lists.newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap));
         JsonNode result;
         try {
             result = monitor.get();
@@ -219,21 +209,12 @@ public class OvsdbClientImpl implements OvsdbClient {
                                                            final MonitorCallBack callback) {
 
         final ImmutableMap<String, MonitorRequest> reqMap = Maps.uniqueIndex(monitorRequest,
-                new Function<MonitorRequest, String>() {
-                    @Override
-                    public String apply(MonitorRequest input) {
-                        return input.getTableName();
-                    }
-                });
+            input -> input.getTableName());
 
         registerCallback(monitorHandle, callback, dbSchema);
 
-        ListenableFuture<JsonNode> monitor = rpc.monitor(new Params() {
-            @Override
-            public List<Object> params() {
-                return Lists.<Object>newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap);
-            }
-        });
+        ListenableFuture<JsonNode> monitor = rpc.monitor(
+            () -> Lists.newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap));
         JsonNode result;
         try {
             result = monitor.get();
@@ -251,12 +232,7 @@ public class OvsdbClientImpl implements OvsdbClient {
 
     @Override
     public void cancelMonitor(final MonitorHandle handler) {
-        ListenableFuture<JsonNode> cancelMonitor = rpc.monitor_cancel(new Params() {
-            @Override
-            public List<Object> params() {
-                return Lists.<Object>newArrayList(handler.getId());
-            }
-        });
+        ListenableFuture<JsonNode> cancelMonitor = rpc.monitor_cancel(() -> Lists.newArrayList(handler.getId()));
 
         JsonNode result = null;
         try {
@@ -331,20 +307,17 @@ public class OvsdbClientImpl implements OvsdbClient {
 
         if (databaseSchema == null) {
             return Futures.transform(
-                    getSchemaFromDevice(Lists.newArrayList(database)),
-                    new Function<Map<String, DatabaseSchema>, DatabaseSchema>() {
-                        @Override
-                        public DatabaseSchema apply(Map<String, DatabaseSchema> result) {
-                            if (result.containsKey(database)) {
-                                DatabaseSchema dbSchema = result.get(database);
-                                dbSchema.populateInternallyGeneratedColumns();
-                                OvsdbClientImpl.this.schemas.put(database, dbSchema);
-                                return dbSchema;
-                            } else {
-                                return null;
-                            }
-                        }
-                    }, executorService);
+                getSchemaFromDevice(Lists.newArrayList(database)),
+                (Function<Map<String, DatabaseSchema>, DatabaseSchema>) result -> {
+                    if (result.containsKey(database)) {
+                        DatabaseSchema dbSchema = result.get(database);
+                        dbSchema.populateInternallyGeneratedColumns();
+                        OvsdbClientImpl.this.schemas.put(database, dbSchema);
+                        return dbSchema;
+                    } else {
+                        return null;
+                    }
+                }, executorService);
         } else {
             return Futures.immediateFuture(databaseSchema);
         }
@@ -366,23 +339,20 @@ public class OvsdbClientImpl implements OvsdbClient {
         }
 
         Futures.transform(rpc.get_schema(Lists.newArrayList(dbNames.get(0))),
-                new com.google.common.base.Function<JsonNode, Void>() {
-                    @Override
-                    public Void apply(JsonNode jsonNode) {
-                        try {
-                            schema.put(dbNames.get(0), DatabaseSchema.fromJson(dbNames.get(0), jsonNode));
-                            if (schema.size() > 1 && !sfuture.isCancelled()) {
-                                populateSchema(dbNames.subList(1, dbNames.size()), schema, sfuture);
-                            } else if (schema.size() == 1) {
-                                sfuture.set(schema);
-                            }
-                        } catch (ParsingException e) {
-                            LOG.warn("Failed to populate schema {}:{}", dbNames, schema, e);
-                            sfuture.setException(e);
-                        }
-                        return null;
+            (Function<JsonNode, Void>) jsonNode -> {
+                try {
+                    schema.put(dbNames.get(0), DatabaseSchema.fromJson(dbNames.get(0), jsonNode));
+                    if (schema.size() > 1 && !sfuture.isCancelled()) {
+                        populateSchema(dbNames.subList(1, dbNames.size()), schema, sfuture);
+                    } else if (schema.size() == 1) {
+                        sfuture.set(schema);
                     }
-                });
+                } catch (ParsingException e) {
+                    LOG.warn("Failed to populate schema {}:{}", dbNames, schema, e);
+                    sfuture.setException(e);
+                }
+                return null;
+            });
     }
 
     public void setRpc(OvsdbRPC rpc) {
index c8d8ddaf64fdeb2bad1e453139ff4e88a4839897..75c7701589d2e7f5b021c6b6f6b0fffb5246d4e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
+ * Copyright © 2014, 2017 Red Hat, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -246,12 +246,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
         final int ovsdbListenerPort = this.listenerPort;
         if (!singletonCreated.getAndSet(true)) {
             LOG.info("startOvsdbManager: Starting");
-            new Thread() {
-                @Override
-                public void run() {
-                    ovsdbManager(ovsdbListenerPort);
-                }
-            }.start();
+            new Thread(() -> ovsdbManager(ovsdbListenerPort)).start();
             return true;
         } else {
             return false;
@@ -267,12 +262,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     public synchronized boolean startOvsdbManagerWithSsl(final int ovsdbListenPort,
                                      final SSLContext sslContext, String[] protocols, String[] cipherSuites) {
         if (!singletonCreated.getAndSet(true)) {
-            new Thread() {
-                @Override
-                public void run() {
-                    ovsdbManagerWithSsl(ovsdbListenPort, sslContext, protocols, cipherSuites);
-                }
-            }.start();
+            new Thread(() -> ovsdbManagerWithSsl(ovsdbListenPort, sslContext, protocols, cipherSuites)).start();
             return true;
         } else {
             return false;
index 42fba8f714961a95e181fff8d947912c0d1f9b35..3563d5156fb770eba984e47bc9ed4ca482b7c979 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 , NEC Corporation and others.  All rights reserved.
+ * Copyright © 2016, 2017 NEC Corporation and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -60,17 +60,14 @@ public class StalePassiveConnectionService implements AutoCloseable {
         // scheduled task for ping response timeout. Connections that don't response to the
         // ping or haven't disconnected after the timeout will be closed
         final ScheduledFuture<?> echoTimeoutFuture =
-                executorService.schedule(new Runnable() {
-                    @Override
-                    public void run() {
-                        for (OvsdbClient client : clientFutureMap.keySet()) {
-                            Future<?> clientFuture = clientFutureMap.get(client);
-                            if (!clientFuture.isDone() && !clientFuture.isCancelled()) {
-                                clientFuture.cancel(true);
-                            }
-                            if (client.isActive()) {
-                                client.disconnect();
-                            }
+                executorService.schedule(() -> {
+                    for (OvsdbClient client : clientFutureMap.keySet()) {
+                        Future<?> clientFuture = clientFutureMap.get(client);
+                        if (!clientFuture.isDone() && !clientFuture.isCancelled()) {
+                            clientFuture.cancel(true);
+                        }
+                        if (client.isActive()) {
+                            client.disconnect();
                         }
                     }
                 }, ECHO_TIMEOUT, TimeUnit.SECONDS);
index 579968b9c1d75203cacebc96027b6a3bfa9cd6ec..d64948d9135eb0f667985777e154df0f3505a55b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015 EBay Software Foundation and others. All rights reserved.
+ * Copyright © 2013, 2017 EBay Software Foundation and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -22,7 +22,6 @@ import com.google.common.util.concurrent.SettableFuture;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import io.netty.channel.Channel;
 
-import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
@@ -87,59 +86,53 @@ public class JsonRpcEndpoint {
 
     public <T> T getClient(final Object context, Class<T> klazz) {
 
-        return Reflection.newProxy(klazz, new InvocationHandler() {
-            @Override
-            public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
-                if (method.getName().equals(OvsdbRPC.REGISTER_CALLBACK_METHOD)) {
-                    if ((args == null) || args.length != 1 || !(args[0] instanceof OvsdbRPC.Callback)) {
-                        return false;
-                    }
-                    requestCallbacks.put(context, (OvsdbRPC.Callback)args[0]);
-                    return true;
+        return Reflection.newProxy(klazz, (proxy, method, args) -> {
+            if (method.getName().equals(OvsdbRPC.REGISTER_CALLBACK_METHOD)) {
+                if ((args == null) || args.length != 1 || !(args[0] instanceof OvsdbRPC.Callback)) {
+                    return false;
                 }
+                requestCallbacks.put(context, (OvsdbRPC.Callback)args[0]);
+                return true;
+            }
 
-                JsonRpc10Request request = new JsonRpc10Request(UUID.randomUUID().toString());
-                request.setMethod(method.getName());
+            JsonRpc10Request request = new JsonRpc10Request(UUID.randomUUID().toString());
+            request.setMethod(method.getName());
 
-                if (args != null && args.length != 0) {
-                    List<Object> params = null;
+            if (args != null && args.length != 0) {
+                List<Object> params = null;
 
-                    if (args.length == 1) {
-                        if (args[0] instanceof Params) {
-                            params = ((Params) args[0]).params();
-                        } else if (args[0] instanceof List) {
-                            params = (List<Object>) args[0];
-                        }
+                if (args.length == 1) {
+                    if (args[0] instanceof Params) {
+                        params = ((Params) args[0]).params();
+                    } else if (args[0] instanceof List) {
+                        params = (List<Object>) args[0];
+                    }
 
-                        if (params == null) {
-                            throw new UnsupportedArgumentException("do not understand this argument yet");
-                        }
-                        request.setParams(params);
+                    if (params == null) {
+                        throw new UnsupportedArgumentException("do not understand this argument yet");
                     }
+                    request.setParams(params);
                 }
+            }
 
-                String requestString = objectMapper.writeValueAsString(request);
-                LOG.trace("getClient Request : {}", requestString);
-
-                SettableFuture<Object> sf = SettableFuture.create();
-                methodContext.put(request.getId(), new CallContext(request, method, sf));
-                FUTURE_REAPER_SERVICE.schedule(new Runnable() {
-                    @Override
-                    public void run() {
-                        CallContext cc = methodContext.remove(request.getId());
-                        if (cc != null) {
-                            if (cc.getFuture().isDone() || cc.getFuture().isCancelled()) {
-                                return;
-                            }
-                            cc.getFuture().cancel(false);
-                        }
+            String requestString = objectMapper.writeValueAsString(request);
+            LOG.trace("getClient Request : {}", requestString);
+
+            SettableFuture<Object> sf = SettableFuture.create();
+            methodContext.put(request.getId(), new CallContext(request, method, sf));
+            FUTURE_REAPER_SERVICE.schedule(() -> {
+                CallContext cc = methodContext.remove(request.getId());
+                if (cc != null) {
+                    if (cc.getFuture().isDone() || cc.getFuture().isCancelled()) {
+                        return;
                     }
-                }, reaperInterval, TimeUnit.MILLISECONDS);
+                    cc.getFuture().cancel(false);
+                }
+            }, reaperInterval, TimeUnit.MILLISECONDS);
 
-                nettyChannel.writeAndFlush(requestString);
+            nettyChannel.writeAndFlush(requestString);
 
-                return sf;
-            }
+            return sf;
         }
         );
     }
index f2c1dbe716bcbc3744c10a071090a234f68203b3..3f7f69fa752b653cb85dcb6b49829cf4df7cf42b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright © 2014, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -29,7 +29,6 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
@@ -55,7 +54,6 @@ import org.opendaylight.ovsdb.southbound.reconciliation.ReconciliationTask;
 import org.opendaylight.ovsdb.southbound.reconciliation.configuration.BridgeConfigReconciliationTask;
 import org.opendaylight.ovsdb.southbound.reconciliation.connection.ConnectionReconciliationTask;
 import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbNodeRemoveCommand;
-import org.opendaylight.ovsdb.southbound.transactions.md.TransactionCommand;
 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
@@ -447,25 +445,22 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
         @SuppressWarnings("unchecked") final InstanceIdentifier<Node> nodeIid =
                 (InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializer(entity.getId());
 
-        txInvoker.invoke(new TransactionCommand() {
-            @Override
-            public void execute(ReadWriteTransaction transaction) {
-                Optional<Node> ovsdbNodeOpt = SouthboundUtil.readNode(transaction, nodeIid);
-                if (ovsdbNodeOpt.isPresent()) {
-                    Node ovsdbNode = ovsdbNodeOpt.get();
-                    OvsdbNodeAugmentation nodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
-                    if (nodeAugmentation != null) {
-                        if (nodeAugmentation.getManagedNodeEntry() != null) {
-                            for (ManagedNodeEntry managedNode : nodeAugmentation.getManagedNodeEntry()) {
-                                transaction.delete(
-                                        LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
-                            }
-                        } else {
-                            LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
+        txInvoker.invoke(transaction -> {
+            Optional<Node> ovsdbNodeOpt = SouthboundUtil.readNode(transaction, nodeIid);
+            if (ovsdbNodeOpt.isPresent()) {
+                Node ovsdbNode = ovsdbNodeOpt.get();
+                OvsdbNodeAugmentation nodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+                if (nodeAugmentation != null) {
+                    if (nodeAugmentation.getManagedNodeEntry() != null) {
+                        for (ManagedNodeEntry managedNode : nodeAugmentation.getManagedNodeEntry()) {
+                            transaction.delete(
+                                    LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
                         }
+                    } else {
+                        LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
                     }
-                    transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
                 }
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
             }
         });
 
index c0fc28a34205ca74bfed5bf03486f2302f6230a9..84180ab7b0aa3e4d5211d757137a457940751c54 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright © 2014, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -25,7 +25,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Queue;
 import java.util.Set;
-import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
@@ -56,70 +55,35 @@ public class TransactUtils {
     private TransactUtils() { }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataBefore() {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return input != null && input.getDataBefore() != null;
-            }
-        };
+        return input -> input != null && input.getDataBefore() != null;
     }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataBeforeAndDataAfter() {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return input != null && input.getDataBefore() != null && input.getDataAfter() != null;
-            }
-        };
+        return input -> input != null && input.getDataBefore() != null && input.getDataAfter() != null;
     }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>> hasNoDataBefore() {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return input != null && input.getDataBefore() == null;
-            }
-        };
+        return input -> input != null && input.getDataBefore() == null;
     }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataAfterAndMatchesFilter(
             final Predicate<DataObjectModification<T>> filter) {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return input != null && input.getDataAfter() != null && filter.apply(input);
-            }
-        };
+        return input -> input != null && input.getDataAfter() != null && filter.apply(input);
     }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>> matchesEverything() {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return true;
-            }
-        };
+        return input -> true;
     }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>> modificationIsDeletion() {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return input != null && input.getModificationType() == DataObjectModification
-                        .ModificationType.DELETE;
-            }
-        };
+        return input -> input != null && input.getModificationType() == DataObjectModification
+                .ModificationType.DELETE;
     }
 
     private static <T extends DataObject> Predicate<DataObjectModification<T>>
         modificationIsDeletionAndHasDataBefore() {
-        return new Predicate<DataObjectModification<T>>() {
-            @Override
-            public boolean apply(@Nullable DataObjectModification<T> input) {
-                return input != null && input.getModificationType() == DataObjectModification
-                        .ModificationType.DELETE && input.getDataBefore() != null;
-            }
-        };
+        return input -> input != null && input.getModificationType() == DataObjectModification
+                .ModificationType.DELETE && input.getDataBefore() != null;
     }
 
     public static Map<InstanceIdentifier<Node>,Node> extractNode(
index a36b51d6d2412fd28e742bc710c7f6c4635dbded..62bc5ad205568474f76faf93a71a0adcc9626e21 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ * Copyright © 2016, 2017 Brocade Communications Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -116,12 +116,7 @@ public class ReconciliationManager implements AutoCloseable {
     public void enqueueForRetry(final ReconciliationTask task) {
         LOG.trace("Reconciliation task re-queued for re-execution {}",task);
         reconTaskManager.cacheTask(task, taskTriager.schedule(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        task.checkReadinessAndProcess();
-                    }
-                }, task.retryDelayInMills(), TimeUnit.MILLISECONDS
+                () -> task.checkReadinessAndProcess(), task.retryDelayInMills(), TimeUnit.MILLISECONDS
             )
         );
     }
index cbc0a5e9c9cbb259737a739181989a1183ad381d..c9765266b7654e75dfa06b91ff7a7ad133434f89 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -24,7 +24,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
@@ -118,12 +117,8 @@ public class InstanceIdentifierCodecTest {
                 .thenReturn(yiid);
 
         mock(InstanceIdentifier.class);
-        when(bindingNormalizedNodeSerializer.fromYangInstanceIdentifier(yiid))
-                .thenAnswer(new Answer<InstanceIdentifier<?>>() {
-                    public InstanceIdentifier<?> answer(InvocationOnMock invocation) throws Exception {
-                        return (InstanceIdentifier<?>) invocation.getArguments()[0];
-                    }
-                });
+        when(bindingNormalizedNodeSerializer.fromYangInstanceIdentifier(yiid)).thenAnswer(
+                (Answer<InstanceIdentifier<?>>) invocation -> (InstanceIdentifier<?>) invocation.getArguments()[0]);
 
         assertEquals("Error, did not return correct InstanceIdentifier<?> object", any(InstanceIdentifier.class),
                 instanceIdCodec.bindingDeserializer(""));
index 4d61546fdf93d9c73ed691c482f68799d257553e..614d642bf4489a777adce7a2511152de33fb1d9a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -27,7 +27,6 @@ import java.util.Map;
 import java.util.Set;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.notation.Column;
@@ -173,20 +172,12 @@ public class SouthboundMapperTest {
     @Test
     public void testCreateDatapathType() throws Exception {
         OvsdbBridgeAugmentation mdsalbridge = mock(OvsdbBridgeAugmentation.class);
-        when(mdsalbridge.getDatapathType()).thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
-            public Class<? extends DatapathTypeBase> answer(
-                    InvocationOnMock invocation) throws Exception {
-                return DatapathTypeNetdev.class;
-            }
-        });
+        when(mdsalbridge.getDatapathType()).thenAnswer(
+                (Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeNetdev.class);
         assertEquals("netdev", SouthboundMapper.createDatapathType(mdsalbridge));
 
-        when(mdsalbridge.getDatapathType()).thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
-            public Class<? extends DatapathTypeBase> answer(
-                    InvocationOnMock invocation) throws Exception {
-                return DatapathTypeSystem.class;
-            }
-        });
+        when(mdsalbridge.getDatapathType()).thenAnswer(
+                (Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeSystem.class);
         assertEquals("system", SouthboundMapper.createDatapathType(mdsalbridge));
     }
 
@@ -204,12 +195,8 @@ public class SouthboundMapperTest {
         ProtocolEntry protocolEntry = mock(ProtocolEntry.class);
         protocolList.add(protocolEntry);
         when(ovsdbBridgeNode.getProtocolEntry()).thenReturn(protocolList);
-        when(protocolEntry.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
-            public Class<? extends OvsdbBridgeProtocolBase> answer(
-                    InvocationOnMock invocation) throws Exception {
-                return OvsdbBridgeProtocolOpenflow10.class;
-            }
-        });
+        when(protocolEntry.getProtocol()).thenAnswer(
+                (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
         Set<String> protocols = new HashSet<>();
         protocols.add("OpenFlow10");
         assertEquals(protocols, SouthboundMapper.createOvsdbBridgeProtocols(ovsdbBridgeNode));
index 226ebe599faa329c3140c5ee6660e674954a448d..0a1895d1ad5a95ac4c1fbdca4f966d39f2879fe8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -24,7 +24,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -64,11 +63,9 @@ public class SouthboundUtilTest {
         ReadOnlyTransaction transaction = mock(ReadOnlyTransaction.class);
         when(db.newReadOnlyTransaction()).thenReturn(transaction);
         when(mn.getManagedBy()).thenReturn(ref);
-        when(ref.getValue()).thenAnswer(new Answer<InstanceIdentifier<Node>>() {
-            public InstanceIdentifier<Node> answer(InvocationOnMock invocation) throws Exception {
-                return (InstanceIdentifier<Node>) mock(InstanceIdentifier.class);
-            }
-        });
+        when(ref.getValue()).thenAnswer(
+                (Answer<InstanceIdentifier<Node>>) invocation -> (InstanceIdentifier<Node>) mock(
+                        InstanceIdentifier.class));
         CheckedFuture<Optional<Node>, ReadFailedException> nf = mock(CheckedFuture.class);
         when(transaction.read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class))).thenReturn(nf);
         doNothing().when(transaction).close();
index 5e10700f538646d26c3c7ca5751adf913201b7f6..871e2ef2aa721b0b5d70a23b8f230ac0d76a77c2 100644 (file)
@@ -22,7 +22,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.ovsdb.lib.notation.Column;
@@ -62,12 +61,8 @@ public class ProtocolRemovedCommandTest {
         PowerMockito.suppress(MemberMatcher.methodsDeclaredIn(InstanceIdentifier.class));
 
         ProtocolEntry protocol = mock(ProtocolEntry.class);
-        when(protocol.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
-            public Class<? extends OvsdbBridgeProtocolBase> answer(
-                    InvocationOnMock invocation) throws Exception {
-                return OvsdbBridgeProtocolOpenflow10.class;
-            }
-        });
+        when(protocol.getProtocol()).thenAnswer(
+                (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
 
         BridgeOperationalState bridgeOpState = mock(BridgeOperationalState.class);
         when(bridgeOpState.getProtocolEntry(any(InstanceIdentifier.class))).thenReturn(Optional.of(protocol));
index 450a26eefaabd5b4a7dd6a51b7c1588f85d948ee..6bf34eab84ff93b8f266e8c0fd0e725d7e7befb0 100644 (file)
@@ -26,7 +26,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.ovsdb.lib.notation.Column;
@@ -91,12 +90,8 @@ public class ProtocolUpdateCommandTest {
 
         OvsdbBridgeName ovsdbBridgeName = mock(OvsdbBridgeName.class);
         when(ovsdbBridge.getBridgeName()).thenReturn(ovsdbBridgeName);
-        when(protocolEntry.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
-            public Class<? extends OvsdbBridgeProtocolBase> answer(
-                    InvocationOnMock invocation) throws Exception {
-                return OvsdbBridgeProtocolOpenflow10.class;
-            }
-        });
+        when(protocolEntry.getProtocol()).thenAnswer(
+                (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
 
         Bridge bridge = mock(Bridge.class);
         PowerMockito.mockStatic(TyperUtils.class);
index ce2880137c58e19757c688ce0201931940d9aabe..210dd203f0388c918f1e85914570607e79aed6cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 , NEC Corporation and others.  All rights reserved.
+ * Copyright © 2016, 2017 NEC Corporation and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -25,7 +25,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -126,12 +125,8 @@ public class BridgeConfigReconciliationTaskTest {
         when(ovsdbBridgeAugmentation.getBridgeName()).thenReturn(ovsdbBridgeName);
         ProtocolEntry protocolEntry = mock(ProtocolEntry.class);
         ProtocolEntryKey protocolEntryKey = mock(ProtocolEntryKey.class);
-        Mockito.when(protocolEntry.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
-            public Class<? extends OvsdbBridgeProtocolBase> answer(
-                    InvocationOnMock invocation) throws Exception {
-                return OvsdbBridgeProtocolOpenflow10.class;
-            }
-        });
+        Mockito.when(protocolEntry.getProtocol()).thenAnswer(
+                (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
         when(protocolEntry.getKey()).thenReturn(protocolEntryKey);
         when(ovsdbBridgeAugmentation.getProtocolEntry()).thenReturn(Arrays.asList(protocolEntry));
 
index d51af5855ee55eab049bfc0380f206e3b6aa0ef9..d6bc9c5c1a1ff8bfb224fa4522e2368a3b625ce5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -28,7 +28,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -332,11 +331,7 @@ public class OpenVSwitchUpdateCommandTest {
         when(column.getData()).thenReturn(set);
         PowerMockito.mockStatic(SouthboundMapper.class);
         when(SouthboundMapper.createInterfaceType(anyString()))
-                .thenAnswer(new Answer<Class<? extends InterfaceTypeBase>>() {
-                    public Class<? extends InterfaceTypeBase> answer(InvocationOnMock invocation) throws Exception {
-                        return InterfaceTypeInternal.class;
-                    }
-                });
+                .thenAnswer((Answer<Class<? extends InterfaceTypeBase>>) invocation -> InterfaceTypeInternal.class);
 
         InterfaceTypeEntry ifEntry = mock(InterfaceTypeEntry.class);
         InterfaceTypeEntryBuilder interfaceTypeEntryBldr = mock(InterfaceTypeEntryBuilder.class);
@@ -363,11 +358,7 @@ public class OpenVSwitchUpdateCommandTest {
         when(column.getData()).thenReturn(set);
         PowerMockito.mockStatic(SouthboundMapper.class);
         when(SouthboundMapper.createDatapathType(anyString()))
-                .thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
-                    public Class<? extends DatapathTypeBase> answer(InvocationOnMock invocation) throws Exception {
-                        return DatapathTypeSystem.class;
-                    }
-                });
+                .thenAnswer((Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeSystem.class);
         DatapathTypeEntry dpEntry = mock(DatapathTypeEntry.class);
         DatapathTypeEntryBuilder datapathTypeEntryBuilder = mock(DatapathTypeEntryBuilder.class);
         PowerMockito.whenNew(DatapathTypeEntryBuilder.class).withNoArguments().thenReturn(datapathTypeEntryBuilder);
index 2c9d421eb1006fae396c138379dc2d5de12628f8..315e2bab3cd711ea86d1beb573fb60c421ed0bfc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -34,7 +34,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -333,11 +332,7 @@ public class OvsdbBridgeUpdateCommandTest {
         when(column.getData()).thenReturn("system");
         PowerMockito.mockStatic(SouthboundMapper.class);
         when(SouthboundMapper.createDatapathType(anyString()))
-                .thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
-                    public Class<? extends DatapathTypeBase> answer(InvocationOnMock invocation) throws Exception {
-                        return DatapathTypeSystem.class;
-                    }
-                });
+                .thenAnswer((Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeSystem.class);
         OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = mock(OvsdbBridgeAugmentationBuilder.class);
         when(ovsdbBridgeAugmentationBuilder.setDatapathType(any(Class.class)))
                 .thenReturn(ovsdbBridgeAugmentationBuilder);
index f940ec0f90ab0834536f7bf39dba5f073282057b..a08a3853c5a873ed693aa2a4cd8b66ba8ff0af5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -35,7 +35,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -422,11 +421,7 @@ public class OvsdbPortUpdateCommandTest {
         when(ovsdbTerminationPointBuilder.setInterfaceUuid(any(Uuid.class))).thenReturn(ovsdbTerminationPointBuilder);
         PowerMockito.mockStatic(SouthboundMapper.class);
         PowerMockito.when(SouthboundMapper.createInterfaceType(anyString()))
-                .thenAnswer(new Answer<Class<? extends InterfaceTypeBase>>() {
-                    public Class<? extends InterfaceTypeBase> answer(InvocationOnMock invocation) throws Exception {
-                        return InterfaceTypeInternal.class;
-                    }
-                });
+                .thenAnswer((Answer<Class<? extends InterfaceTypeBase>>) invocation -> InterfaceTypeInternal.class);
         when(ovsdbTerminationPointBuilder.setInterfaceType(any(Class.class))).thenReturn(ovsdbTerminationPointBuilder);
         suppress(method(OvsdbPortUpdateCommand.class, "updateOfPort", Interface.class,
                 OvsdbTerminationPointAugmentationBuilder.class));