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%2FClientBackedReadWriteTransactionTest.java;h=a404030f0e734feb59c419ad4e0333afb8283ea8;hb=refs%2Fchanges%2F61%2F96761%2F2;hp=97adcb35f05addaf28612955d16561de2586c8cd;hpb=7e62b4a59f9e43bcd0585845f1aeb55c44199f27;p=controller.git 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 97adcb35f0..a404030f0e 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 @@ -7,20 +7,24 @@ */ 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.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.databroker.actors.dds.ClientTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +@RunWith(MockitoJUnitRunner.StrictStubs.class) public class ClientBackedReadWriteTransactionTest extends ClientBackedTransactionTest { private ClientBackedReadWriteTransaction object; @@ -28,40 +32,33 @@ public class ClientBackedReadWriteTransactionTest @Mock private ClientTransaction delegate; @Mock - private NormalizedNode data; - @Mock - private DOMStoreThreePhaseCommitCohort readyCohort; + private NormalizedNode data; @Override - ClientBackedReadWriteTransaction object() throws Exception { + ClientBackedReadWriteTransaction object() { return object; } @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - Mockito.doReturn(TRANSACTION_ID).when(delegate).getIdentifier(); - Mockito.doReturn(readyCohort).when(delegate).ready(); + 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 ClientBackedReadWriteTransaction(delegate, null); } @Test public void testRead() throws Exception { - final FluentFuture>> result = object().read(YangInstanceIdentifier.EMPTY); - final Optional> resultData = result.get(); - Assert.assertTrue(resultData.isPresent()); - Assert.assertEquals(data, resultData.get()); + final FluentFuture> result = object().read(YangInstanceIdentifier.empty()); + final Optional resultData = result.get(); + assertTrue(resultData.isPresent()); + assertEquals(data, resultData.get()); } @Test public void testExists() throws Exception { - Assert.assertTrue(object().exists(YangInstanceIdentifier.EMPTY).get()); + assertEquals(Boolean.TRUE, object().exists(YangInstanceIdentifier.empty()).get()); } }