X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2FClientBackedReadTransactionTest.java;h=08316b83911c5bb763962009bfafe869d9083112;hb=HEAD;hp=ee8280f4e936b8c958266e149af7809bb48e9563;hpb=808a02471eef0f975c13fc948f933fac34ada387;p=controller.git 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 ee8280f4e9..08316b8391 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,63 +7,55 @@ */ package org.opendaylight.controller.cluster.databroker; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +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 java.util.Optional; 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.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +@RunWith(MockitoJUnitRunner.StrictStubs.class) public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest { private ClientBackedReadTransaction object; @Mock - private NormalizedNode data; + private ContainerNode 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.of()); + doReturn(immediateFluentFuture(Optional.of(data))).when(delegate).read(YangInstanceIdentifier.of()); - object = new ClientBackedReadTransaction(delegate, null); + object = new ClientBackedReadTransaction(delegate, null, null); } @Test public void testRead() throws Exception { - final CheckedFuture>, ReadFailedException> result = object().read( - YangInstanceIdentifier.EMPTY); - final Optional> resultData = result.get(); - Assert.assertTrue(resultData.isPresent()); - Assert.assertEquals(data, resultData.get()); + assertEquals(Optional.of(data), object().read(YangInstanceIdentifier.of()).get()); } @Test public void testExists() throws Exception { - final CheckedFuture result = object().exists(YangInstanceIdentifier.EMPTY); - Assert.assertTrue(result.get()); + assertEquals(Boolean.TRUE, object().exists(YangInstanceIdentifier.of()).get()); } -} \ No newline at end of file +}