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());
}
};
}
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))));
}
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());
}
Aggregations