From a85197fcfedf2894b98439ea0ad66b3f5a0eb00b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 28 Mar 2019 17:55:17 +0100 Subject: [PATCH] Fix transaction mocking We should not confuse FluentFutures and CheckedFutures, as the latter is deprecated and with Guava 27 they are not compatible anyway. Change-Id: I7489b4470df6fa435aab190b6e38eaf154522fe7 Signed-off-by: Robert Varga --- .../databroker/ClientBackedReadTransactionTest.java | 7 ++++--- .../databroker/ClientBackedReadWriteTransactionTest.java | 7 ++++--- .../cluster/datastore/LocalTransactionContextTest.java | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransactionTest.java index 2d09073228..35d9d112a4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransactionTest.java @@ -10,8 +10,9 @@ package org.opendaylight.controller.cluster.databroker; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; +import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture; +import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateTrueFluentFuture; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.Optional; import org.junit.Before; @@ -45,8 +46,8 @@ public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest doReturn(CLIENT_ID).when(clientContext).getIdentifier(); doReturn(TRANSACTION_ID).when(delegate).getIdentifier(); - doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(delegate).exists(YangInstanceIdentifier.EMPTY); - doReturn(Futures.immediateCheckedFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.EMPTY); + doReturn(immediateTrueFluentFuture()).when(delegate).exists(YangInstanceIdentifier.EMPTY); + doReturn(immediateFluentFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.EMPTY); object = new ClientBackedReadTransaction(delegate, null, null); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java index 5696839032..ad1fd1bf46 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java @@ -10,9 +10,10 @@ package org.opendaylight.controller.cluster.databroker; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; +import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture; +import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateTrueFluentFuture; import com.google.common.util.concurrent.FluentFuture; -import com.google.common.util.concurrent.Futures; import java.util.Optional; import org.junit.Before; import org.junit.Test; @@ -46,8 +47,8 @@ public class ClientBackedReadWriteTransactionTest doReturn(TRANSACTION_ID).when(delegate).getIdentifier(); doReturn(readyCohort).when(delegate).ready(); - doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(delegate).exists(YangInstanceIdentifier.EMPTY); - doReturn(Futures.immediateCheckedFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.EMPTY); + doReturn(immediateTrueFluentFuture()).when(delegate).exists(YangInstanceIdentifier.EMPTY); + doReturn(immediateFluentFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.EMPTY); object = new ClientBackedReadWriteTransaction(delegate, null); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContextTest.java index 1fb2f8eea5..3364fc3cc4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContextTest.java @@ -15,7 +15,6 @@ import static org.mockito.Mockito.verify; import akka.actor.ActorSelection; import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; import org.junit.Before; import org.junit.Test; @@ -29,6 +28,7 @@ import org.opendaylight.controller.cluster.datastore.modification.WriteModificat import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import scala.concurrent.Future; @@ -93,7 +93,7 @@ public class LocalTransactionContextTest { public void testRead() { YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY; NormalizedNode normalizedNode = mock(NormalizedNode.class); - doReturn(Futures.immediateCheckedFuture(Optional.of(normalizedNode))).when(readWriteTransaction) + doReturn(FluentFutures.immediateFluentFuture(Optional.of(normalizedNode))).when(readWriteTransaction) .read(yangInstanceIdentifier); localTransactionContext.executeRead(new ReadData(yangInstanceIdentifier, DataStoreVersions.CURRENT_VERSION), SettableFuture.create(), null); @@ -103,7 +103,7 @@ public class LocalTransactionContextTest { @Test public void testExists() { YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY; - doReturn(Futures.immediateCheckedFuture(true)).when(readWriteTransaction).exists(yangInstanceIdentifier); + doReturn(FluentFutures.immediateTrueFluentFuture()).when(readWriteTransaction).exists(yangInstanceIdentifier); localTransactionContext.executeRead(new DataExists(yangInstanceIdentifier, DataStoreVersions.CURRENT_VERSION), SettableFuture.create(), null); verify(readWriteTransaction).exists(yangInstanceIdentifier); -- 2.36.6