Search in sources :

Example 11 with TopLevelListBuilder

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

the class WriteParentListenAugmentTest method writeNodeListenAugment.

@Test
public void writeNodeListenAugment() throws Exception {
    final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
    DataBroker dataBroker = testContext.getDataBroker();
    ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> dclRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, AUGMENT_WILDCARDED_PATH, change -> event.set(change), DataChangeScope.SUBTREE);
    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    TopLevelList tll = new TopLevelListBuilder().setKey(TLL_KEY).addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment("one")).build();
    transaction.put(LogicalDatastoreType.OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
    transaction.submit().get(5, TimeUnit.SECONDS);
    AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get(1000, TimeUnit.MILLISECONDS);
    assertTrue(receivedEvent.getCreatedData().containsKey(AUGMENT_TLL_PATH));
    dclRegistration.close();
    final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
    transaction2.put(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two"));
    transaction2.submit().get(5, TimeUnit.SECONDS);
    TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, AUGMENT_TLL_PATH).get(5, TimeUnit.SECONDS).get();
    assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TreeComplexUsesAugment(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment) 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) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) AsyncDataChangeEvent(org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent) AbstractDataServiceTest(org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest) Test(org.junit.Test)

Example 12 with TopLevelListBuilder

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

the class BackwardsCompatibleNotificationBrokerTest method createTestData.

private TwoLevelListChanged createTestData() {
    final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
    tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().setKey(new TopLevelListKey("test")).build()));
    return tb.build();
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) TwoLevelListChangedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey)

Example 13 with TopLevelListBuilder

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

the class ListsBindingUtils method topLevelList.

public static TopLevelList topLevelList(final TopLevelListKey key, final TreeComplexUsesAugment augment) {
    TopLevelListBuilder builder = new TopLevelListBuilder().setKey(key);
    builder.addAugmentation(TreeComplexUsesAugment.class, augment);
    return builder.build();
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder)

Example 14 with TopLevelListBuilder

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

the class EmptyLeafTest method testCaseWithEmptyLeafType.

@Test
public void testCaseWithEmptyLeafType() {
    final TopLevelList withEmptyCase = new TopLevelListBuilder().withKey(TOP_FOO_KEY).setChoiceInList(new EmptyLeafBuilder().setEmptyType(Empty.value()).build()).build();
    final Entry<YangInstanceIdentifier, NormalizedNode> dom = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, withEmptyCase);
    final Entry<InstanceIdentifier<?>, DataObject> readed = codecContext.fromNormalizedNode(dom.getKey(), dom.getValue());
    final ChoiceInList list = ((TopLevelList) readed.getValue()).getChoiceInList();
    assertTrue(list instanceof EmptyLeaf);
    assertNotNull(((EmptyLeaf) list).getEmptyType());
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) EmptyLeaf(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeaf) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ChoiceInList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.ChoiceInList) EmptyLeafBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.EmptyLeafBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 15 with TopLevelListBuilder

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

the class NormalizedNodeSerializeDeserializeTest method orderedLisFromNormalized.

@Test
public void orderedLisFromNormalized() {
    final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE)).withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE)).withChild(ImmutableUserMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME)).withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo")).withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
    final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, foo);
    final TopLevelList topLevelList = new TopLevelListBuilder().withKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(List.of(new NestedListBuilder().withKey(new NestedListKey("foo")).build(), new NestedListBuilder().withKey(new NestedListKey("bar")).build())).build();
    assertEquals(topLevelList, entry.getValue());
}
Also used : TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) NestedListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NestedListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder)15 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)13 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder)7 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)5 NestedListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder)5 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)3 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)3 Top (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top)3 TopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)3 ArrayList (java.util.ArrayList)2 AbstractDataServiceTest (org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest)2 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)2 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)2