X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2FClientBackedReadTransactionTest.java;h=bcaedfa188ef8e10799f565ef58265522cdfaf54;hp=7d41885ca59459f0daf47eb5424307ad1b209c99;hb=68c7159811d38ba956cfabcc67e64acb778aa19a;hpb=7e62b4a59f9e43bcd0585845f1aeb55c44199f27 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 7d41885ca5..bcaedfa188 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 @@ -7,62 +7,61 @@ */ package org.opendaylight.controller.cluster.databroker; -import com.google.common.util.concurrent.Futures; +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.ListenableFuture; import java.util.Optional; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; +import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.controller.cluster.access.client.ClientActorContext; import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +@RunWith(MockitoJUnitRunner.StrictStubs.class) public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest { private ClientBackedReadTransaction object; @Mock - private NormalizedNode data; + private NormalizedNode data; @Mock private ClientActorContext clientContext; @Mock private ClientSnapshot delegate; @Override - ClientBackedReadTransaction object() throws Exception { + ClientBackedReadTransaction object() { return object; } @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - Mockito.doReturn(CLIENT_ID).when(clientContext).getIdentifier(); - Mockito.doReturn(TRANSACTION_ID).when(delegate).getIdentifier(); + public void setUp() { + doReturn(TRANSACTION_ID).when(delegate).getIdentifier(); - Mockito.doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(delegate) - .exists(YangInstanceIdentifier.EMPTY); - Mockito.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); } @Test public void testRead() throws Exception { - final ListenableFuture>> result = object().read( - YangInstanceIdentifier.EMPTY); - final Optional> resultData = result.get(); - Assert.assertTrue(resultData.isPresent()); - Assert.assertEquals(data, resultData.get()); + final ListenableFuture> result = object().read(YangInstanceIdentifier.empty()); + final Optional resultData = result.get(); + assertTrue(resultData.isPresent()); + assertEquals(data, resultData.get()); } @Test public void testExists() throws Exception { - final ListenableFuture result = object().exists(YangInstanceIdentifier.EMPTY); - Assert.assertTrue(result.get()); + final ListenableFuture result = object().exists(YangInstanceIdentifier.empty()); + assertEquals(Boolean.TRUE, result.get()); } }