Search in sources :

Example 1 with TransactionModification

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

the class AbstractProxyTransactionTest method hasPath.

protected static BaseMatcher<TransactionModification> hasPath(final YangInstanceIdentifier path) {
    return new BaseMatcher<TransactionModification>() {

        @Override
        public boolean matches(final Object item) {
            return path.equals(((TransactionModification) item).getPath());
        }

        @Override
        public void describeTo(final Description description) {
            description.appendValue(path);
        }

        @Override
        public void describeMismatch(final Object item, final Description description) {
            final TransactionModification modification = (TransactionModification) item;
            description.appendText("was ").appendValue(modification.getPath());
        }
    };
}
Also used : Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification)

Example 2 with TransactionModification

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

the class RemoteProxyTransactionTest method testModification.

private <T extends TransactionModification> void testModification(final Runnable modification, final Class<T> cls, final YangInstanceIdentifier expectedPath) {
    modification.run();
    final ModifyTransactionRequest request = transaction.commitRequest(false);
    final List<TransactionModification> modifications = request.getModifications();
    Assert.assertEquals(1, modifications.size());
    Assert.assertThat(modifications, hasItem(both(isA(cls)).and(hasPath(expectedPath))));
}
Also used : TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)

Example 3 with TransactionModification

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

the class LocalReadWriteProxyTransactionTest method applyModifyTransactionRequest.

private void applyModifyTransactionRequest(final boolean coordinated) {
    final TestProbe probe = createProbe();
    final ModifyTransactionRequestBuilder builder = new ModifyTransactionRequestBuilder(TRANSACTION_ID, probe.ref());
    final TransactionModification write = new TransactionWrite(PATH_1, DATA_1);
    final TransactionModification merge = new TransactionMerge(PATH_2, DATA_2);
    final TransactionModification delete = new TransactionDelete(PATH_3);
    builder.addModification(write);
    builder.addModification(merge);
    builder.addModification(delete);
    builder.setSequence(0L);
    builder.setCommit(coordinated);
    final ModifyTransactionRequest request = builder.build();
    final Consumer<Response<?, ?>> callback = createCallbackMock();
    transaction.replayModifyTransactionRequest(request, callback, Ticker.systemTicker().read());
    verify(modification).write(PATH_1, DATA_1);
    verify(modification).merge(PATH_2, DATA_2);
    verify(modification).delete(PATH_3);
    final CommitLocalTransactionRequest commitRequest = getTester().expectTransactionRequest(CommitLocalTransactionRequest.class);
    Assert.assertEquals(modification, commitRequest.getModification());
    Assert.assertEquals(coordinated, commitRequest.isCoordinated());
}
Also used : Response(org.opendaylight.controller.cluster.access.concepts.Response) TransactionModification(org.opendaylight.controller.cluster.access.commands.TransactionModification) ModifyTransactionRequestBuilder(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder) TestProbe(akka.testkit.TestProbe) TransactionWrite(org.opendaylight.controller.cluster.access.commands.TransactionWrite) TransactionDelete(org.opendaylight.controller.cluster.access.commands.TransactionDelete) TransactionMerge(org.opendaylight.controller.cluster.access.commands.TransactionMerge) ModifyTransactionRequest(org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest) CommitLocalTransactionRequest(org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)

Aggregations

TransactionModification (org.opendaylight.controller.cluster.access.commands.TransactionModification)3 ModifyTransactionRequest (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequest)2 TestProbe (akka.testkit.TestProbe)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1 CommitLocalTransactionRequest (org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest)1 ModifyTransactionRequestBuilder (org.opendaylight.controller.cluster.access.commands.ModifyTransactionRequestBuilder)1 TransactionDelete (org.opendaylight.controller.cluster.access.commands.TransactionDelete)1 TransactionMerge (org.opendaylight.controller.cluster.access.commands.TransactionMerge)1 TransactionWrite (org.opendaylight.controller.cluster.access.commands.TransactionWrite)1 Response (org.opendaylight.controller.cluster.access.concepts.Response)1