Fix static methods and convert to lambdas 21/38321/2
authorRobert Varga <rovarga@cisco.com>
Tue, 3 May 2016 12:01:47 +0000 (14:01 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 9 May 2016 09:06:51 +0000 (09:06 +0000)
This fixes warnings about static methods and as an auto-save action, converts
functional interface implementations to lambdas.

Change-Id: Id4486516282685fb85f9cfc6e512096662475d53
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java

index ec5f024..02ba015 100644 (file)
@@ -1186,13 +1186,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         final String node1ID = "node1";
         final String node2ID = "node2";
 
-        PeerAddressResolver peerAddressResolver = new PeerAddressResolver() {
-            @Override
-            public String resolve(String peerId) {
-                return peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
-                    peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
-            }
-        };
+        PeerAddressResolver peerAddressResolver = peerId -> peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
+            peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(node1ID, false), new ServerInfo(node2ID, true)));
@@ -1256,13 +1251,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         final String node1ID = "node1";
         final String node2ID = "node2";
 
-        PeerAddressResolver peerAddressResolver = new PeerAddressResolver() {
-            @Override
-            public String resolve(String peerId) {
-                return peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
-                    peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
-            }
-        };
+        PeerAddressResolver peerAddressResolver = peerId -> peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
+            peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
 
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
@@ -1335,13 +1325,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         final String node1ID = "node1";
         final String node2ID = "node2";
 
-        configParams.setPeerAddressResolver(new PeerAddressResolver() {
-            @Override
-            public String resolve(String peerId) {
-                return peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
-                    peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
-            }
-        });
+        configParams.setPeerAddressResolver(peerId -> peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
+            peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null);
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(node1ID, false), new ServerInfo(node2ID, true)));
@@ -1403,7 +1388,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         LOG.info("testChangeToVotingWithNoLeaderAndOtherLeaderElected ending");
     }
 
-    private void verifyRaftState(RaftState expState, RaftActor... raftActors) {
+    private static void verifyRaftState(RaftState expState, RaftActor... raftActors) {
         Stopwatch sw = Stopwatch.createStarted();
         while(sw.elapsed(TimeUnit.SECONDS) <= 5) {
             for(RaftActor raftActor: raftActors) {
index 9d6ff5e..d49c7d4 100644 (file)
@@ -24,7 +24,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator;
-import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
@@ -52,15 +51,15 @@ public class NormalizedNodePrunerTest {
         MockitoAnnotations.initMocks(this);
     }
 
-    private NormalizedNodePruner prunerFullSchema(YangInstanceIdentifier path) {
+    private static NormalizedNodePruner prunerFullSchema(YangInstanceIdentifier path) {
         return new NormalizedNodePruner(path, FULL_SCHEMA);
     }
 
-    private NormalizedNodePruner prunerNoAugSchema(YangInstanceIdentifier path) {
+    private static NormalizedNodePruner prunerNoAugSchema(YangInstanceIdentifier path) {
         return new NormalizedNodePruner(path, NO_AUG_SCHEMA);
     }
 
-    private NormalizedNodePruner prunerNoTestSchema(YangInstanceIdentifier path) {
+    private static NormalizedNodePruner prunerNoTestSchema(YangInstanceIdentifier path) {
         return new NormalizedNodePruner(path, NO_TEST_SCHEMA);
     }
 
@@ -145,14 +144,10 @@ public class NormalizedNodePrunerTest {
             return 0;
         }
         final AtomicInteger count = new AtomicInteger();
-        new NormalizedNodeNavigator(new NormalizedNodeVisitor() {
-
-            @Override
-            public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
-                if(!(normalizedNode.getIdentifier() instanceof AugmentationIdentifier)) {
-                    if (normalizedNode.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) {
-                        count.incrementAndGet();
-                    }
+        new NormalizedNodeNavigator((level, parentPath, normalizedNode1) -> {
+            if(!(normalizedNode1.getIdentifier() instanceof AugmentationIdentifier)) {
+                if (normalizedNode1.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) {
+                    count.incrementAndGet();
                 }
             }
         }).navigate(YangInstanceIdentifier.EMPTY.toString(), normalizedNode);
index 0168313..9db9635 100644 (file)
@@ -113,7 +113,7 @@ public class MemberNode {
             cleanedUp = true;
             kit.cleanup(configDataStore);
             kit.cleanup(operDataStore);
-            kit.shutdownActorSystem(kit.getSystem(), Boolean.TRUE);
+            IntegrationTestKit.shutdownActorSystem(kit.getSystem(), Boolean.TRUE);
         }
     }
 
@@ -150,12 +150,7 @@ public class MemberNode {
                 type(datastore.getActorContext().getDataStoreName()).build().toString());
         }
 
-        verifyRaftState(datastore, shardName, new RaftStateVerifier() {
-            @Override
-            public void verify(OnDemandRaftState raftState) {
-                assertEquals("Peers for shard " + shardName, peerIds, raftState.getPeerAddresses().keySet());
-            }
-        });
+        verifyRaftState(datastore, shardName, raftState -> assertEquals("Peers for shard " + shardName, peerIds, raftState.getPeerAddresses().keySet()));
     }
 
     public static void verifyNoShardPresent(DistributedDataStore datastore, String shardName) {