use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList in project controller by opendaylight.
the class AbstractDataBrokerTestTest method writeInitialState.
// copy/pasted from Bug1125RegressionTest.writeInitialState()
private void writeInitialState() throws TransactionCommitFailedException {
WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder().setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping("foo").build()).build();
initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), topLevelList(TOP_FOO_KEY, fooAugment));
initialTx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList in project controller by opendaylight.
the class BrokerIntegrationTest method simpleModifyOperation.
@Test
public void simpleModifyOperation() throws Exception {
DataBroker dataBroker = testContext.getDataBroker();
Optional<TopLevelList> tllFoo = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, FOO_PATH).checkedGet(5, TimeUnit.SECONDS);
assertFalse(tllFoo.isPresent());
TopLevelList tllFooData = createTll(TLL_FOO_KEY);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.CONFIGURATION, FOO_PATH, tllFooData);
transaction.submit().get(5, TimeUnit.SECONDS);
Optional<TopLevelList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, FOO_PATH).checkedGet(5, TimeUnit.SECONDS);
assertTrue(readedData.isPresent());
assertEquals(tllFooData.getKey(), readedData.get().getKey());
TopLevelList nodeBarData = createTll(TLL_BAR_KEY);
TopLevelList nodeBazData = createTll(TLL_BAZ_KEY);
final WriteTransaction insertMoreTr = dataBroker.newWriteOnlyTransaction();
insertMoreTr.put(LogicalDatastoreType.CONFIGURATION, BAR_PATH, nodeBarData);
insertMoreTr.put(LogicalDatastoreType.CONFIGURATION, BAZ_PATH, nodeBazData);
insertMoreTr.submit().get(5, TimeUnit.SECONDS);
Optional<Top> top = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, TOP_PATH).checkedGet(5, TimeUnit.SECONDS);
assertTrue(top.isPresent());
assertEquals(3, top.get().getTopLevelList().size());
// We create transaction no 2
final WriteTransaction removalTransaction = dataBroker.newWriteOnlyTransaction();
// We remove node 1
removalTransaction.delete(LogicalDatastoreType.CONFIGURATION, BAR_PATH);
// We commit transaction
removalTransaction.submit().get(5, TimeUnit.SECONDS);
Optional<TopLevelList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, BAR_PATH).checkedGet(5, TimeUnit.SECONDS);
assertFalse(readedData2.isPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList in project controller by opendaylight.
the class CrossBrokerRpcTest method knockKnock.
private static KnockKnockInputBuilder knockKnock(final InstanceIdentifier<TopLevelList> listId) {
KnockKnockInputBuilder builder = new KnockKnockInputBuilder();
builder.setKnockerId(listId);
return builder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList in project genius by opendaylight.
the class DataTreeEventCallbackRegistrarTest method testExceptionInCallbackMustBeLogged.
@Test
public void testExceptionInCallbackMustBeLogged() throws TransactionCommitFailedException, InterruptedException {
logCaptureRule.expectLastErrorMessageContains("TestConsumer");
AtomicBoolean added = new AtomicBoolean(false);
DataTreeEventCallbackRegistrar dataTreeEventCallbackRegistrar = new DataTreeEventCallbackRegistrarImpl(db);
dataTreeEventCallbackRegistrar.onAdd(OPERATIONAL, FOO_PATH, new Function<TopLevelList, NextAction>() {
@Override
public NextAction apply(TopLevelList topLevelList) {
added.set(true);
throw new IllegalStateException("TEST");
}
@Override
public String toString() {
return "TestConsumer";
}
});
db1.syncWrite(OPERATIONAL, FOO_PATH, FOO_DATA);
await().untilTrue(added);
// TODO see above we can remove this once we can await DataBroker listeners
// The sleep () is required :( so that the throw new IllegalStateException really leads to an ERROR log,
// because the (easily) await().untilTrue(...) could theoretically complete immediately after added.set(true)
// but before the throw new IllegalStateException("TEST") and LOG. To make this more reliable and without sleep
// would require more work inside DataBroker to be able to await listener event processing.
Thread.sleep(100);
}
Aggregations