Search in sources :

Example 1 with ModifyTransactionRequestBuilder

use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.

the class LocalReadOnlyProxyTransactionTest method testApplyModifyTransactionRequest.

@Test
public void testApplyModifyTransactionRequest() throws Exception {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    builder.setSequence(0);
    builder.setAbort();
    final ModifyTransactionRequest request = builder.build();
    transaction.replayModifyTransactionRequest(request, createCallbackMock(), Ticker.systemTicker().read());
    getTester().expectTransactionRequest(AbortLocalTransactionRequest.class);
}
Also used : ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 2 with ModifyTransactionRequestBuilder

use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.

the class LocalReadOnlyProxyTransactionTest method testApplyModifyTransactionRequestNotAbort.

@Test
public void testApplyModifyTransactionRequestNotAbort() throws Exception {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    builder.setSequence(0);
    builder.setReady();
    final ModifyTransactionRequest request = builder.build();
    assertOperationThrowsException(() -> transaction.replayModifyTransactionRequest(request, createCallbackMock(), Ticker.systemTicker().read()), VerifyException.class);
}
Also used : ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 3 with ModifyTransactionRequestBuilder

use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.

the class RemoteProxyTransactionTest method testForwardToRemoteModifyAbort.

@Test
public void testForwardToRemoteModifyAbort() throws Exception {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    builder.setSequence(0L);
    builder.setAbort();
    final ModifyTransactionRequest request = builder.build();
    final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
    Assert.assertEquals(request.getTarget(), received.getTarget());
    Assert.assertTrue(received.getPersistenceProtocol().isPresent());
    Assert.assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
}
Also used : ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) Test(org.junit.Test)

Example 4 with ModifyTransactionRequestBuilder

use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.

the class FrontendReadWriteTransactionTest method testModifyAfterReady.

@Test(expected = IllegalStateException.class)
public void testModifyAfterReady() throws RequestException {
    final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(TX_ID, mock(ActorRef.class));
    b.setSequence(0);
    b.setReady();
    final TransactionRequest<?> readyReq = b.build();
    assertNotNull(handleRequest(readyReq));
    verify(mockParent).finishTransaction(same(shardTransaction));
    b.setSequence(1);
    b.addModification(mock(TransactionModification.class));
    handleRequest(b.build());
}
Also used : TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) ActorRef(akka.actor.ActorRef) Test(org.junit.Test)

Example 5 with ModifyTransactionRequestBuilder

use of org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder in project controller by opendaylight.

the class FrontendReadWriteTransactionTest method testReadAfterReady.

@Test(expected = IllegalStateException.class)
public void testReadAfterReady() throws RequestException {
    final ModifyTransactionRequestBuilder b = new ModifyTransactionRequestBuilder(TX_ID, mock(ActorRef.class));
    b.setSequence(0);
    b.setReady();
    final TransactionRequest<?> readyReq = b.build();
    assertNotNull(handleRequest(readyReq));
    verify(mockParent).finishTransaction(same(shardTransaction));
    handleRequest(new ReadTransactionRequest(TX_ID, 0, mock(ActorRef.class), YangInstanceIdentifier.EMPTY, true));
}
Also used : ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) ActorRef(akka.actor.ActorRef) ReadTransactionRequest(org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest) Test(org.junit.Test)

Aggregations

ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)19 Test (org.junit.Test)17 ActorRef (akka.actor.ActorRef)7 TestProbe (akka.testkit.TestProbe)7 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)7 Response (org.opendaylight.controller.cluster.access.concepts.Response)5 TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)3 ReadTransactionRequest (org.opendaylight.controller.cluster.access.commands.ReadTransactionRequest)2 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)2 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)2 TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)2 TransactionPurgeRequest (org.opendaylight.controller.cluster.access.commands.TransactionPurgeRequest)2 TransactionPurgeResponse (org.opendaylight.controller.cluster.access.commands.TransactionPurgeResponse)2 RequestEnvelope (org.opendaylight.controller.cluster.access.concepts.RequestEnvelope)2 RequestException (org.opendaylight.controller.cluster.access.concepts.RequestException)2 SliceOptions (org.opendaylight.controller.cluster.messaging.SliceOptions)2 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)1 FailureEnvelope (org.opendaylight.controller.cluster.access.concepts.FailureEnvelope)1 LocalHistoryIdentifier (org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)1 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)1