*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertOperationThrowsException;
import akka.testkit.TestProbe;
+import com.google.common.base.Ticker;
import com.google.common.base.VerifyException;
-import org.junit.Assert;
+import java.util.Optional;
import org.junit.Test;
import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
public class LocalReadOnlyProxyTransactionTest extends LocalProxyTransactionTest<LocalReadOnlyProxyTransaction> {
-
private DataTreeSnapshot snapshot;
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
protected LocalReadOnlyProxyTransaction createTransaction(final ProxyHistory parent,
final TransactionIdentifier id,
final DataTreeSnapshot snapshot) {
- when(snapshot.readNode(PATH_1)).thenReturn(com.google.common.base.Optional.of(DATA_1));
- when(snapshot.readNode(PATH_3)).thenReturn(com.google.common.base.Optional.absent());
+ when(snapshot.readNode(PATH_1)).thenReturn(Optional.of(DATA_1));
+ when(snapshot.readNode(PATH_3)).thenReturn(Optional.empty());
this.snapshot = snapshot;
return new LocalReadOnlyProxyTransaction(parent, id, this.snapshot);
}
@Test
public void testIsSnapshotOnly() {
- Assert.assertTrue(transaction.isSnapshotOnly());
+ assertTrue(transaction.isSnapshotOnly());
}
@Test
public void testReadOnlyView() {
- Assert.assertEquals(snapshot, transaction.readOnlyView());
+ assertEquals(snapshot, transaction.readOnlyView());
}
+ @Test
@Override
- @Test(expected = UnsupportedOperationException.class)
- public void testDirectCommit() throws Exception {
- transaction.directCommit();
+ public void testDirectCommit() {
+ assertThrows(UnsupportedOperationException.class, () -> transaction.directCommit());
}
+ @Test
@Override
- @Test(expected = UnsupportedOperationException.class)
- public void testCanCommit() throws Exception {
- transaction.canCommit(new VotingFuture<>(new Object(), 1));
+ public void testCanCommit() {
+ assertThrows(UnsupportedOperationException.class,
+ () -> transaction.canCommit(new VotingFuture<>(new Object(), 1)));
}
+ @Test
@Override
- @Test(expected = UnsupportedOperationException.class)
- public void testPreCommit() throws Exception {
- transaction.preCommit(new VotingFuture<>(new Object(), 1));
+ public void testPreCommit() {
+ assertThrows(UnsupportedOperationException.class,
+ () -> transaction.preCommit(new VotingFuture<>(new Object(), 1)));
}
+ @Test
@Override
- @Test(expected = UnsupportedOperationException.class)
- public void testDoCommit() throws Exception {
- transaction.doCommit(new VotingFuture<>(new Object(), 1));
+ public void testDoCommit() {
+ assertThrows(UnsupportedOperationException.class,
+ () -> transaction.doCommit(new VotingFuture<>(new Object(), 1)));
}
+ @Test
@Override
- @Test(expected = UnsupportedOperationException.class)
public void testDelete() {
- transaction.delete(PATH_1);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.delete(PATH_1));
}
@Override
- @Test(expected = UnsupportedOperationException.class)
public void testMerge() {
- transaction.merge(PATH_1, DATA_1);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.merge(PATH_1, DATA_1));
}
+ @Test
@Override
- @Test(expected = UnsupportedOperationException.class)
public void testWrite() {
- transaction.write(PATH_1, DATA_1);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.write(PATH_1, DATA_1));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testDoDelete() {
- transaction.doDelete(PATH_1);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.doDelete(PATH_1));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testDoMerge() {
- transaction.doMerge(PATH_1, DATA_1);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.doMerge(PATH_1, DATA_1));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testDoWrite() {
- transaction.doWrite(PATH_1, DATA_1);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.doWrite(PATH_1, DATA_1));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testCommitRequest() {
- transaction.commitRequest(true);
+ assertThrows(UnsupportedOperationException.class, () -> transaction.commitRequest(true));
}
@Test
- public void testApplyModifyTransactionRequest() throws Exception {
+ public void testApplyModifyTransactionRequest() {
final TestProbe probe = createProbe();
final ModifyTransactionRequestBuilder builder =
new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
builder.setSequence(0);
builder.setAbort();
final ModifyTransactionRequest request = builder.build();
- transaction.applyModifyTransactionRequest(request, createCallbackMock());
+ transaction.replayModifyTransactionRequest(request, createCallbackMock(), Ticker.systemTicker().read());
getTester().expectTransactionRequest(AbortLocalTransactionRequest.class);
}
builder.setSequence(0);
builder.setReady();
final ModifyTransactionRequest request = builder.build();
- assertOperationThrowsException(() -> transaction.applyModifyTransactionRequest(request, createCallbackMock()),
- VerifyException.class);
+ assertOperationThrowsException(() -> transaction.replayModifyTransactionRequest(request, createCallbackMock(),
+ Ticker.systemTicker().read()), VerifyException.class);
}
-
-}
\ No newline at end of file
+}