Search in sources :

Example 1 with List11Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder in project controller by opendaylight.

the class WriteParentReadChildTest method writeParentReadChild.

/**
 * The scenario tests writing parent node, which also contains child items
 * and then reading child directly, by specifying path to the child.
 * Expected behaviour is child is returned.
 */
@Test
public void writeParentReadChild() throws Exception {
    DataBroker dataBroker = testContext.getDataBroker();
    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    List11 list11 = // 
    new List11Builder().setKey(// 
    LIST11_KEY).setAttrStr("primary").build();
    List1 list1 = new List1Builder().setKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build();
    transaction.put(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA, list1, true);
    transaction.submit().get(5, TimeUnit.SECONDS);
    Optional<List1> readList1 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA).get(1000, TimeUnit.MILLISECONDS);
    assertTrue(readList1.isPresent());
    Optional<? extends DataObject> readList11 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).get(5, TimeUnit.SECONDS);
    assertNotNull("Readed flow should not be null.", readList11);
    assertTrue(readList11.isPresent());
    assertEquals(list11, readList11.get());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) List11(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11) List1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1) List11Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder) List1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Builder) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AbstractDataServiceTest(org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 AbstractDataServiceTest (org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest)1 List1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1)1 List1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Builder)1 List11 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11)1 List11Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder)1