sal-distributed-datastore: use lambdas
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / TransactionChainProxyTest.java
index 72d47711da6da82afb273df07365bc403ad29d05..9fd0849bf16199682fbc3c3bc5ea631ba5884751 100644 (file)
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.opendaylight.controller.cluster.datastore.TransactionType.READ_WRITE;
 import static org.opendaylight.controller.cluster.datastore.TransactionType.WRITE_ONLY;
+
 import akka.actor.ActorRef;
 import akka.util.Timeout;
 import java.util.concurrent.CountDownLatch;
@@ -75,6 +76,7 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
 
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void testClose() {
         new TransactionChainProxy(mockComponentFactory, historyId).close();
@@ -117,6 +119,7 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
      * initiated until the first one completes its read future.
      */
     @Test
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void testChainedWriteOnlyTransactions() throws Exception {
         dataStoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true);
 
@@ -149,18 +152,15 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
 
             final AtomicReference<Exception> caughtEx = new AtomicReference<>();
             final CountDownLatch write2Complete = new CountDownLatch(1);
-            new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
-                    } catch (Exception e) {
-                        caughtEx.set(e);
-                    } finally {
-                        write2Complete.countDown();
-                    }
+            new Thread(() -> {
+                try {
+                    writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
+                } catch (Exception e) {
+                    caughtEx.set(e);
+                } finally {
+                    write2Complete.countDown();
                 }
-            }.start();
+            }).start();
 
             assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS));
 
@@ -187,6 +187,7 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
      * initiated until the first one completes its read future.
      */
     @Test
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void testChainedReadWriteTransactions() throws Exception {
         try (TransactionChainProxy txChainProxy = new TransactionChainProxy(mockComponentFactory, historyId)) {
 
@@ -220,18 +221,15 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
 
             final AtomicReference<Exception> caughtEx = new AtomicReference<>();
             final CountDownLatch write2Complete = new CountDownLatch(1);
-            new Thread() {
-                @Override
-                public void run() {
-                    try {
-                        writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
-                    } catch (Exception e) {
-                        caughtEx.set(e);
-                    } finally {
-                        write2Complete.countDown();
-                    }
+            new Thread(() -> {
+                try {
+                    writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2);
+                } catch (Exception e) {
+                    caughtEx.set(e);
+                } finally {
+                    write2Complete.countDown();
                 }
-            }.start();
+            }).start();
 
             assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS));
 
@@ -268,8 +266,6 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest {
             NormalizedNode<?, ?> writeNode1 = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
             writeTx1.write(TestModel.TEST_PATH, writeNode1);
 
-            NormalizedNode<?, ?> writeNode2 = ImmutableNodes.containerNode(TestModel.OUTER_LIST_QNAME);
-
             txChainProxy.newWriteOnlyTransaction();
         }
     }