*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.TRANSACTION_ID;
import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertFutureEquals;
-import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertOperationThrowsException;
import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.getWithTimeout;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
-import org.junit.Assert;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
transaction.read(PATH);
}
- @Test
- public void testOpenCloseCursor() throws Exception {
- final DOMDataTreeWriteCursor cursor = getHandle().openCursor();
- getHandle().closeCursor(cursor);
- getHandle().openCursor().delete(PATH.getLastPathArgument());
- verify(modification).delete(PATH);
- }
-
- @Test
- public void testOpenSecondCursor() throws Exception {
- getHandle().openCursor();
- assertOperationThrowsException(getHandle()::openCursor, IllegalStateException.class);
- }
-
@Test
public void testExists() throws Exception {
- final CheckedFuture<Boolean, ReadFailedException> exists = getHandle().exists(PATH);
+ final FluentFuture<Boolean> exists = getHandle().exists(PATH);
verify(modification).readNode(PATH);
- Assert.assertTrue(getWithTimeout(exists));
+ assertEquals(Boolean.TRUE, getWithTimeout(exists));
}
@Test
public void testRead() throws Exception {
- final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> resultFuture = getHandle().read(PATH);
+ final FluentFuture<Optional<NormalizedNode<?, ?>>> resultFuture = getHandle().read(PATH);
verify(modification).readNode(PATH);
final Optional<NormalizedNode<?, ?>> result = getWithTimeout(resultFuture);
- Assert.assertTrue(result.isPresent());
- Assert.assertEquals(DATA, result.get());
+ assertTrue(result.isPresent());
+ assertEquals(DATA, result.get());
}
@Test
- public void testDelete() throws Exception {
+ public void testDelete() {
getHandle().delete(PATH);
verify(modification).delete(PATH);
}
@Test
- public void testMerge() throws Exception {
+ public void testMerge() {
getHandle().merge(PATH, DATA);
verify(modification).merge(PATH, DATA);
}
@Test
- public void testWrite() throws Exception {
+ public void testWrite() {
getHandle().write(PATH, DATA);
verify(modification).write(PATH, DATA);
}
@Test
public void testReadyEmpty() throws Exception {
final DOMStoreThreePhaseCommitCohort cohort = getHandle().ready();
- assertFutureEquals(true, cohort.canCommit());
+ assertFutureEquals(Boolean.TRUE, cohort.canCommit());
assertFutureEquals(null, cohort.preCommit());
assertFutureEquals(null, cohort.commit());
}
final ListenableFuture<Boolean> actual = cohort.canCommit();
final CommitLocalTransactionRequest request =
backendRespondToRequest(CommitLocalTransactionRequest.class, response);
- Assert.assertEquals(modification, request.getModification());
- assertFutureEquals(true, actual);
+ assertEquals(modification, request.getModification());
+ assertFutureEquals(Boolean.TRUE, actual);
assertFutureEquals(null, cohort.preCommit());
assertFutureEquals(null, cohort.commit());
}
checkClosed();
}
-}
\ No newline at end of file
+}