use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.
the class LocalProxyTransactionTest method testForwardToRemoteCommit.
@Override
@Test
public void testForwardToRemoteCommit() throws Exception {
final TestProbe probe = createProbe();
final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
final CommitLocalTransactionRequest request = new CommitLocalTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), modification, null, true);
doAnswer(LocalProxyTransactionTest::applyToCursorAnswer).when(modification).applyToCursor(any());
final ModifyTransactionRequest modifyRequest = testForwardToRemote(request, ModifyTransactionRequest.class);
verify(modification).applyToCursor(any());
Assert.assertTrue(modifyRequest.getPersistenceProtocol().isPresent());
Assert.assertEquals(PersistenceProtocol.THREE_PHASE, modifyRequest.getPersistenceProtocol().get());
checkModifications(modifyRequest);
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.
the class LocalReadWriteProxyTransaction method sealModification.
private void sealModification() {
Preconditions.checkState(sealedModification == null, "Transaction %s is already sealed", this);
final CursorAwareDataTreeModification mod = getModification();
mod.ready();
sealedModification = mod;
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.
the class AbstractDataStoreClientBehaviorTest method testGetConnection.
@Test
public void testGetConnection() throws Exception {
// set up data tree mock
final CursorAwareDataTreeModification modification = mock(CursorAwareDataTreeModification.class);
when(modification.readNode(YangInstanceIdentifier.EMPTY)).thenReturn(Optional.empty());
final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
when(snapshot.newModification()).thenReturn(modification);
final DataTree dataTree = mock(DataTree.class);
when(dataTree.takeSnapshot()).thenReturn(snapshot);
final TestProbe backendProbe = new TestProbe(system, "backend");
final long shard = 0L;
behavior.createTransaction().read(YangInstanceIdentifier.EMPTY);
final AbstractClientConnection<ShardBackendInfo> connection = behavior.getConnection(shard);
// check cached connection for same shard
Assert.assertSame(connection, behavior.getConnection(shard));
final ConnectClientRequest connectClientRequest = actorContextProbe.expectMsgClass(ConnectClientRequest.class);
Assert.assertEquals(CLIENT_ID, connectClientRequest.getTarget());
final long sequence = 0L;
Assert.assertEquals(sequence, connectClientRequest.getSequence());
actorContextProbe.reply(new ConnectClientSuccess(CLIENT_ID, sequence, backendProbe.ref(), Collections.emptyList(), dataTree, 3));
Assert.assertEquals(clientActorProbe.ref(), connection.localActor());
// capture and execute command passed to client context
final InternalCommand<ShardBackendInfo> command = clientActorProbe.expectMsgClass(InternalCommand.class);
command.execute(behavior);
// check, whether command was reaplayed
verify(modification).readNode(YangInstanceIdentifier.EMPTY);
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification in project controller by opendaylight.
the class LocalReadWriteProxyTransaction method commitRequest.
@Override
CommitLocalTransactionRequest commitRequest(final boolean coordinated) {
final CursorAwareDataTreeModification mod = getModification();
final CommitLocalTransactionRequest ret = new CommitLocalTransactionRequest(getIdentifier(), nextSequence(), localActor(), mod, recordedFailure, coordinated);
closedException = this::submittedException;
return ret;
}
Aggregations