*/
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.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.cluster.access.client.ClientActorContext;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
private ClientSnapshot delegate;
@Override
- ClientBackedReadTransaction object() throws Exception {
+ ClientBackedReadTransaction object() {
return object;
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
MockitoAnnotations.initMocks(this);
- Mockito.doReturn(CLIENT_ID).when(clientContext).getIdentifier();
- Mockito.doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
+ doReturn(CLIENT_ID).when(clientContext).getIdentifier();
+ 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<Optional<NormalizedNode<?, ?>>> result = object().read(
- YangInstanceIdentifier.EMPTY);
+ final ListenableFuture<Optional<NormalizedNode<?, ?>>> result = object().read(YangInstanceIdentifier.empty());
final Optional<NormalizedNode<?, ?>> resultData = result.get();
- Assert.assertTrue(resultData.isPresent());
- Assert.assertEquals(data, resultData.get());
+ assertTrue(resultData.isPresent());
+ assertEquals(data, resultData.get());
}
@Test
public void testExists() throws Exception {
- final ListenableFuture<Boolean> result = object().exists(YangInstanceIdentifier.EMPTY);
- Assert.assertTrue(result.get());
+ final ListenableFuture<Boolean> result = object().exists(YangInstanceIdentifier.empty());
+ assertEquals(Boolean.TRUE, result.get());
}
}