Search in sources :

Example 6 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.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());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 7 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.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();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment) ContainerWithUsesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder) TreeComplexUsesAugmentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder)

Example 8 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.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());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AbstractDataServiceTest(org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest) Test(org.junit.Test)

Example 9 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.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;
}
Also used : KnockKnockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInputBuilder)

Example 10 with TopLevelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList in project mdsal by opendaylight.

the class WriteTransactionTest method testMergeCreateParentsSuccess.

@Test
public void testMergeCreateParentsSuccess() throws InterruptedException, ExecutionException {
    final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE);
    writeTx.commit().get();
    final ReadTransaction readTx = getDataBroker().newReadOnlyTransaction();
    final Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
    assertTrue("Top node must exists after commit", topNode.isPresent());
    final Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
    assertTrue("List node must exists after commit", listNode.isPresent());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) Test(org.junit.Test) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)

Aggregations

Test (org.junit.Test)61 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)32 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)26 Assert.assertEquals (org.junit.Assert.assertEquals)23 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)23 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)22 OptimisticLockFailedException (org.opendaylight.mdsal.common.api.OptimisticLockFailedException)21 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList)20 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)18 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)14 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)13 ExecutionException (java.util.concurrent.ExecutionException)12 Assert.assertThrows (org.junit.Assert.assertThrows)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)12 Before (org.junit.Before)11 AbstractDataTreeChangeListenerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataTreeChangeListenerTest)11 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)11 IOException (java.io.IOException)10 OPERATIONAL (org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL)10 TreeComplexUsesAugmentBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugmentBuilder)10