use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project controller by opendaylight.
the class DataTreeChangeListenerTest method testWildcardNotificationOfPreexistingData.
@SuppressWarnings("unchecked")
@Test
public void testWildcardNotificationOfPreexistingData() throws Exception {
InstanceIdentifier<Top> id = InstanceIdentifier.builder(Top.class).build();
ArrayList<TopLevelList> list = new ArrayList<>();
list.add(new TopLevelListBuilder().setName("name").build());
TopBuilder builder = new TopBuilder().setTopLevelList(list);
DataBroker dataBroker = getDataBroker();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.OPERATIONAL, id, builder.build());
assertCommit(writeTransaction.submit());
DataTreeChangeListener<TopLevelList> listener = mock(DataTreeChangeListener.class);
InstanceIdentifier<TopLevelList> wildcard = InstanceIdentifier.builder(Top.class).child(TopLevelList.class).build();
dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, wildcard), listener);
verify(listener, timeout(1000)).onDataTreeChanged(Matchers.anyObject());
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project controller by opendaylight.
the class DataTreeChangeListenerTest method deleteTx.
private WriteTransaction deleteTx(final InstanceIdentifier<?> path) {
final WriteTransaction tx = dataBrokerImpl.newWriteOnlyTransaction();
tx.delete(LogicalDatastoreType.OPERATIONAL, path);
return tx;
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project controller by opendaylight.
the class DataTreeChangeListenerTest method putTx.
private <T extends DataObject> WriteTransaction putTx(final InstanceIdentifier<T> path, final T data) {
final WriteTransaction tx = dataBrokerImpl.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, path, data);
return tx;
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project controller by opendaylight.
the class WriteTransactionTest method testPutCreateParentsSuccess.
@Test
public void testPutCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE, true);
writeTx.submit().checkedGet();
ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
assertTrue("Top node must exists after commit", topNode.isPresent());
Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit", listNode.isPresent());
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project controller by opendaylight.
the class WriteTransactionTest method testMergeCreateParentsSuccess.
@Test
public void testMergeCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE, true);
writeTx.submit().checkedGet();
ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
assertTrue("Top node must exists after commit", topNode.isPresent());
Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit", listNode.isPresent());
}
Aggregations