From 5d11b7f405f1bd63527f5ac9d79bd5b6073668f3 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 29 Dec 2023 01:46:03 +0100 Subject: [PATCH] Clean up ClientBackedDataStoreTest Use local variable type inference to simplify code a bit. Change-Id: I5d6c116f40fb84250b3f775e92b98de558dde14d Signed-off-by: Robert Varga --- .../databroker/ClientBackedDataStoreTest.java | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java index fa8b1ef993..2c73eac3a7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedDataStoreTest.java @@ -29,10 +29,6 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransacti import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient; import org.opendaylight.controller.cluster.datastore.DatastoreContext; import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class ClientBackedDataStoreTest { @@ -49,16 +45,12 @@ public class ClientBackedDataStoreTest { @Mock private DataStoreClient clientActor; - @Mock private ActorUtils actorUtils; - @Mock private ClientLocalHistory clientLocalHistory; - @Mock private ClientTransaction clientTransaction; - @Mock private ClientSnapshot clientSnapshot; @@ -75,40 +67,32 @@ public class ClientBackedDataStoreTest { @Test public void testCreateTransactionChain() { - try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( - actorUtils, UNKNOWN_ID, clientActor)) { - final DOMStoreTransactionChain txChain = clientBackedDataStore.createTransactionChain(); - assertNotNull(txChain); + try (var clientBackedDataStore = new ClientBackedDataStore(actorUtils, UNKNOWN_ID, clientActor)) { + assertNotNull(clientBackedDataStore.createTransactionChain()); verify(clientActor, times(1)).createLocalHistory(); } } @Test public void testNewReadOnlyTransaction() { - try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( - actorUtils, UNKNOWN_ID, clientActor)) { - final DOMStoreReadTransaction tx = clientBackedDataStore.newReadOnlyTransaction(); - assertNotNull(tx); + try (var clientBackedDataStore = new ClientBackedDataStore(actorUtils, UNKNOWN_ID, clientActor)) { + assertNotNull(clientBackedDataStore.newReadOnlyTransaction()); verify(clientActor, times(1)).createSnapshot(); } } @Test public void testNewWriteOnlyTransaction() { - try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( - actorUtils, UNKNOWN_ID, clientActor)) { - final DOMStoreWriteTransaction tx = clientBackedDataStore.newWriteOnlyTransaction(); - assertNotNull(tx); + try (var clientBackedDataStore = new ClientBackedDataStore(actorUtils, UNKNOWN_ID, clientActor)) { + assertNotNull(clientBackedDataStore.newWriteOnlyTransaction()); verify(clientActor, times(1)).createTransaction(); } } @Test public void testNewReadWriteTransaction() { - try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore( - actorUtils, UNKNOWN_ID, clientActor)) { - final DOMStoreReadWriteTransaction tx = clientBackedDataStore.newReadWriteTransaction(); - assertNotNull(tx); + try (var clientBackedDataStore = new ClientBackedDataStore(actorUtils, UNKNOWN_ID, clientActor)) { + assertNotNull(clientBackedDataStore.newReadWriteTransaction()); verify(clientActor, times(1)).createTransaction(); } } -- 2.36.6