From af6eac63d0dbda851b0a755ffbcef24d61471f44 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 29 May 2020 19:06:31 +0200 Subject: [PATCH] Clean up binding-util tests Ditch Truth and use assertThrows() to test exactly what we need. Change-Id: Ic19ccf7efc67cd0c0ecd03e2c3cdcdac97629ce7 Signed-off-by: Robert Varga --- binding/mdsal-binding-util/pom.xml | 8 - .../ManagedNewTransactionRunnerImplTest.java | 167 ++++++++---------- ...tryingManagedNewTransactionRunnerTest.java | 17 +- .../binding/util/TransactionAdapterTest.java | 50 +++--- 4 files changed, 101 insertions(+), 141 deletions(-) diff --git a/binding/mdsal-binding-util/pom.xml b/binding/mdsal-binding-util/pom.xml index 2ab1f9a6b9..259de25096 100644 --- a/binding/mdsal-binding-util/pom.xml +++ b/binding/mdsal-binding-util/pom.xml @@ -34,14 +34,6 @@ true - - com.google.truth - truth - - - com.google.truth.extensions - truth-java8-extension - org.opendaylight.mdsal mdsal-binding-test-model diff --git a/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/ManagedNewTransactionRunnerImplTest.java b/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/ManagedNewTransactionRunnerImplTest.java index d5bb9a2a4b..6b2df7c4b5 100644 --- a/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/ManagedNewTransactionRunnerImplTest.java +++ b/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/ManagedNewTransactionRunnerImplTest.java @@ -7,11 +7,10 @@ */ package org.opendaylight.mdsal.binding.util; -import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY; import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path; import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList; @@ -20,6 +19,7 @@ import static org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL; import java.io.IOException; import java.util.Optional; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import org.junit.Before; import org.junit.Test; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -53,7 +53,7 @@ public class ManagedNewTransactionRunnerImplTest extends AbstractConcurrentDataB super(true); } - protected ManagedNewTransactionRunner createManagedNewTransactionRunnerToTest(DataBroker dataBroker) { + protected ManagedNewTransactionRunner createManagedNewTransactionRunnerToTest(final DataBroker dataBroker) { return new ManagedNewTransactionRunnerImpl(dataBroker); } @@ -136,142 +136,117 @@ public class ManagedNewTransactionRunnerImplTest extends AbstractConcurrentDataB @Test public void testCallWithNewTypedWriteOnlyTransactionAndSubmitPutButLaterException() throws Exception { - try { - managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> { + Future future = managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, + writeTx -> { writeTx.put(TEST_PATH, newTestDataObject()); // We now throw an arbitrary kind of checked (not unchecked!) exception here throw new IOException("something didn't quite go as expected..."); - }).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof IOException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + }); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(IOException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testCallWithNewTypedReadWriteTransactionAndSubmitPutButLaterException() throws Exception { - try { - managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, writeTx -> { + Future future = managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> { writeTx.put(TEST_PATH, newTestDataObject()); // We now throw an arbitrary kind of checked (not unchecked!) exception here throw new IOException("something didn't quite go as expected..."); - }).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof IOException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + }); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(IOException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testApplyWithNewReadWriteTransactionAndSubmitPutButLaterException() throws Exception { - try { - managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, - writeTx -> { - writeTx.put(TEST_PATH, newTestDataObject()); - // We now throw an arbitrary kind of checked (not unchecked!) exception here - throw new IOException("something didn't quite go as expected..."); - }).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof IOException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + Future future = managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> { + writeTx.put(TEST_PATH, newTestDataObject()); + // We now throw an arbitrary kind of checked (not unchecked!) exception here + throw new IOException("something didn't quite go as expected..."); + }); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(IOException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testCallWithNewTypedWriteOnlyTransactionCommitFailedException() throws Exception { - try { - testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); - managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, - writeTx -> writeTx.put(TEST_PATH, newTestDataObject())).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof TransactionCommitFailedException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); + Future future = managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, + writeTx -> writeTx.put(TEST_PATH, newTestDataObject())); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(TransactionCommitFailedException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testCallWithNewTypedReadWriteTransactionCommitFailedException() throws Exception { - try { - testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); - managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, - writeTx -> writeTx.put(TEST_PATH, newTestDataObject())).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof TransactionCommitFailedException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); + Future future = managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> writeTx.put(TEST_PATH, newTestDataObject())); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(TransactionCommitFailedException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testApplyWithNewReadWriteTransactionCommitFailedException() throws Exception { - try { - testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); - managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, - writeTx -> { - writeTx.put(TEST_PATH, newTestDataObject()); - return 1; - }).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof TransactionCommitFailedException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); + Future future = managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> { + writeTx.put(TEST_PATH, newTestDataObject()); + return 1; + }); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(TransactionCommitFailedException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testCallWithNewTypedWriteOnlyTransactionOptimisticLockFailedException() throws Exception { - try { - testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!")); - managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, - writeTx -> writeTx.put(TEST_PATH, newTestDataObject())).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof OptimisticLockFailedException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!")); + Future future = managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, + writeTx -> writeTx.put(TEST_PATH, newTestDataObject())); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(OptimisticLockFailedException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testCallWithNewTypedReadWriteTransactionOptimisticLockFailedException() throws Exception { - try { - testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!")); - managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, - writeTx -> writeTx.put(TEST_PATH, newTestDataObject())).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof OptimisticLockFailedException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!")); + Future future = managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> writeTx.put(TEST_PATH, newTestDataObject())); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(OptimisticLockFailedException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testApplyWithNewReadWriteTransactionOptimisticLockFailedException() throws Exception { - try { - testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!")); - managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, - writeTx -> { - writeTx.put(TEST_PATH, newTestDataObject()); - return 1; - }).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertThat(e.getCause() instanceof OptimisticLockFailedException).isTrue(); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + testableDataBroker.failCommits(2, new OptimisticLockFailedException("bada boum bam!")); + Future future = managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> { + writeTx.put(TEST_PATH, newTestDataObject()); + return 1; + }); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(OptimisticLockFailedException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } - private Optional syncReadOptional(LogicalDatastoreType datastoreType, - InstanceIdentifier path) throws ExecutionException, InterruptedException { + private Optional syncReadOptional(final LogicalDatastoreType datastoreType, + final InstanceIdentifier path) throws ExecutionException, InterruptedException { try (ReadTransaction tx = getDataBroker().newReadOnlyTransaction()) { return tx.read(datastoreType, path).get(); } } - T syncRead(LogicalDatastoreType datastoreType, InstanceIdentifier path) + T syncRead(final LogicalDatastoreType datastoreType, final InstanceIdentifier path) throws ExecutionException, InterruptedException { return syncReadOptional(datastoreType, path).get(); } diff --git a/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/RetryingManagedNewTransactionRunnerTest.java b/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/RetryingManagedNewTransactionRunnerTest.java index 97d1e6afe3..c44f50da9e 100644 --- a/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/RetryingManagedNewTransactionRunnerTest.java +++ b/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/RetryingManagedNewTransactionRunnerTest.java @@ -10,7 +10,6 @@ package org.opendaylight.mdsal.binding.util; import static org.junit.Assert.assertEquals; import static org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL; -import org.junit.Assert; import org.junit.Test; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -27,7 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.te public class RetryingManagedNewTransactionRunnerTest extends ManagedNewTransactionRunnerImplTest { @Override - protected ManagedNewTransactionRunner createManagedNewTransactionRunnerToTest(DataBroker dataBroker) { + protected ManagedNewTransactionRunner createManagedNewTransactionRunnerToTest(final DataBroker dataBroker) { return new RetryingManagedNewTransactionRunner(dataBroker); } @@ -39,7 +38,7 @@ public class RetryingManagedNewTransactionRunnerTest extends ManagedNewTransacti TopLevelList data = newTestDataObject(); managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> writeTx.put(TEST_PATH, data)).get(); - Assert.assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); + assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Override @@ -50,7 +49,7 @@ public class RetryingManagedNewTransactionRunnerTest extends ManagedNewTransacti TopLevelList data = newTestDataObject(); managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, writeTx -> writeTx.put(TEST_PATH, data)).get(); - Assert.assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); + assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Override @@ -64,7 +63,7 @@ public class RetryingManagedNewTransactionRunnerTest extends ManagedNewTransacti writeTx.put(TEST_PATH, data); return 1; }).get()); - Assert.assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); + assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test @@ -74,21 +73,21 @@ public class RetryingManagedNewTransactionRunnerTest extends ManagedNewTransacti managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> { tx.put(TEST_PATH, data); - Assert.assertEquals(data, tx.read(TEST_PATH).get().get()); + assertEquals(data, tx.read(TEST_PATH).get().get()); }).get(); - Assert.assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); + assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testApplyWithNewReadWriteTransactionReadFailedException() throws Exception { testableDataBroker.failReads(2, new ReadFailedException("bada boum bam!")); TopLevelList data = newTestDataObject(); - Assert.assertEquals(data, managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit( + assertEquals(data, managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit( OPERATIONAL, tx -> { tx.put(TEST_PATH, data); return tx.read(TEST_PATH).get().get(); }).get()); - Assert.assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); + assertEquals(data, syncRead(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } } diff --git a/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/TransactionAdapterTest.java b/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/TransactionAdapterTest.java index 3e46562aa7..ac87071e50 100644 --- a/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/TransactionAdapterTest.java +++ b/binding/mdsal-binding-util/src/test/java/org/opendaylight/mdsal/binding/util/TransactionAdapterTest.java @@ -7,10 +7,10 @@ */ package org.opendaylight.mdsal.binding.util; -import static com.google.common.truth.Truth8.assertThat; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.TOP_FOO_KEY; import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.path; import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList; @@ -18,6 +18,7 @@ import static org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL; import java.util.Optional; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import org.junit.Before; import org.junit.Test; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -35,8 +36,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * Test for {@link TransactionAdapter}. */ -// This is a test for a deprecated class -@SuppressWarnings("deprecation") +@Deprecated public class TransactionAdapterTest extends AbstractConcurrentDataBrokerTest { private static final InstanceIdentifier TEST_PATH = path(TOP_FOO_KEY); @@ -44,7 +44,7 @@ public class TransactionAdapterTest extends AbstractConcurrentDataBrokerTest { private ManagedNewTransactionRunner managedNewTransactionRunner; private DataBrokerFailuresImpl testableDataBroker; - private ManagedNewTransactionRunner createManagedNewTransactionRunnerToTest(DataBroker dataBroker) { + private ManagedNewTransactionRunner createManagedNewTransactionRunnerToTest(final DataBroker dataBroker) { return new ManagedNewTransactionRunnerImpl(dataBroker); } @@ -75,28 +75,22 @@ public class TransactionAdapterTest extends AbstractConcurrentDataBrokerTest { @Test public void testAdaptedWriteTransactionFailsOnInvalidDatastore() throws Exception { - try { - managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, - writeTx -> TransactionAdapter.toWriteTransaction(writeTx).put(LogicalDatastoreType.CONFIGURATION, - TEST_PATH, newTestDataObject())).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof IllegalArgumentException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + Future future = managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, + writeTx -> TransactionAdapter.toWriteTransaction(writeTx).put(LogicalDatastoreType.CONFIGURATION, + TEST_PATH, newTestDataObject())); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(IllegalArgumentException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test public void testAdaptedReadWriteTransactionFailsOnInvalidDatastore() throws Exception { - try { - managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, - writeTx -> TransactionAdapter.toReadWriteTransaction(writeTx).put(LogicalDatastoreType.CONFIGURATION, - TEST_PATH, newTestDataObject())).get(); - fail("This should have led to an ExecutionException!"); - } catch (ExecutionException e) { - assertTrue(e.getCause() instanceof IllegalArgumentException); - } - assertThat(syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)).isEmpty(); + Future future = managedNewTransactionRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, + writeTx -> TransactionAdapter.toReadWriteTransaction(writeTx).put(LogicalDatastoreType.CONFIGURATION, + TEST_PATH, newTestDataObject())); + ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); + assertThat(ex.getCause(), instanceOf(IllegalArgumentException.class)); + assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); } @Test(expected = ExecutionException.class) @@ -129,15 +123,15 @@ public class TransactionAdapterTest extends AbstractConcurrentDataBrokerTest { return topLevelList(TOP_FOO_KEY, fooAugment); } - private Optional syncReadOptional(LogicalDatastoreType datastoreType, - InstanceIdentifier path) throws ExecutionException, InterruptedException { + private Optional syncReadOptional(final LogicalDatastoreType datastoreType, + final InstanceIdentifier path) throws ExecutionException, InterruptedException { try (ReadTransaction tx = getDataBroker().newReadOnlyTransaction()) { return tx.read(datastoreType, path).get(); } } - private T syncRead(LogicalDatastoreType datastoreType, InstanceIdentifier path) - throws ExecutionException, InterruptedException { + private T syncRead(final LogicalDatastoreType datastoreType, + final InstanceIdentifier path) throws ExecutionException, InterruptedException { return syncReadOptional(datastoreType, path).get(); } } -- 2.36.6