Search in sources :

Example 6 with TopBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder in project mdsal by opendaylight.

the class Mdsal108Test method testDelete.

@Test
public void testDelete() {
    DataBroker dataBroker = getDataBroker();
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    final TopLevelList item = new TopLevelListBuilder().setName("name").build();
    TopBuilder builder = new TopBuilder().setTopLevelList(Collections.singletonMap(item.key(), item));
    writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Top.class), builder.build());
    assertCommit(writeTransaction.commit());
    InstanceIdentifier<TopLevelList> id = InstanceIdentifier.builder(Top.class).child(TopLevelList.class, new TopLevelListKey("name")).build();
    ReadWriteTransaction writeTransaction1 = dataBroker.newReadWriteTransaction();
    writeTransaction1.delete(LogicalDatastoreType.OPERATIONAL, id);
    assertCommit(writeTransaction1.commit());
    ReadWriteTransaction writeTransaction2 = dataBroker.newReadWriteTransaction();
    writeTransaction2.delete(LogicalDatastoreType.OPERATIONAL, id);
    assertCommit(writeTransaction2.commit());
}
Also used : ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList) ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey) Test(org.junit.Test) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)

Example 7 with TopBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder in project mdsal by opendaylight.

the class NormalizedNodeSerializeDeserializeTest method orderedleafListToNormalized.

@Test
public void orderedleafListToNormalized() {
    Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
    Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
    ContainerNode containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TOP_QNAME)).withChild(ImmutableUserLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME)).withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo")).withValue("foo").build()).build()).build();
    assertEquals(containerNode, entry.getValue());
}
Also used : TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 8 with TopBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder in project mdsal by opendaylight.

the class NormalizedNodeSerializeDeserializeTest method augmentMultipleChoices.

@Test
public void augmentMultipleChoices() {
    final QName augmentChoice1QName = AugmentChoice1.QNAME;
    final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
    final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
    final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
    final AugmentationIdentifier aug1Id = new AugmentationIdentifier(Set.of(augmentChoice1QName));
    final AugmentationIdentifier aug2Id = new AugmentationIdentifier(Set.of(augmentChoice2QName));
    final NodeIdentifier augmentChoice1Id = new NodeIdentifier(augmentChoice1QName);
    final NodeIdentifier augmentChoice2Id = new NodeIdentifier(augmentChoice2QName);
    final NodeIdentifier containerId = new NodeIdentifier(containerQName);
    final TopBuilder tBuilder = new TopBuilder();
    final TopChoiceAugment1Builder tca1Builder = new TopChoiceAugment1Builder();
    final Case1Builder c1Builder = new Case1Builder();
    final TopChoiceAugment2Builder tca2Builder = new TopChoiceAugment2Builder();
    final Case11Builder c11Builder = new Case11Builder();
    final Case11ChoiceCaseContainerBuilder cccc1Builder = new Case11ChoiceCaseContainerBuilder();
    cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
    c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
    tca2Builder.setAugmentChoice2(c11Builder.build());
    c1Builder.addAugmentation(tca2Builder.build());
    tca1Builder.setAugmentChoice1(c1Builder.build());
    tBuilder.addAugmentation(tca1Builder.build());
    final Top top = tBuilder.build();
    final Entry<YangInstanceIdentifier, NormalizedNode> biResult = codecContext.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
    final NormalizedNode topNormalized = containerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME)).withChild(augmentationBuilder().withNodeIdentifier(aug1Id).withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id).withChild(augmentationBuilder().withNodeIdentifier(aug2Id).withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id).withChild(containerBuilder().withNodeIdentifier(containerId).withChild(leafNode(leafQName, "leaf-value")).build()).build()).build()).build()).build()).build();
    assertEquals(BI_TOP_PATH, biResult.getKey());
    assertEquals(topNormalized, biResult.getValue());
    final Entry<InstanceIdentifier<?>, DataObject> baResult = codecContext.fromNormalizedNode(BI_TOP_PATH, topNormalized);
    assertEquals(InstanceIdentifier.create(Top.class), baResult.getKey());
    assertEquals(top, baResult.getValue());
}
Also used : AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder) Case1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment1.augment.choice1.Case1Builder) QName(org.opendaylight.yangtools.yang.common.QName) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Case11Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment2.augment.choice2.Case11Builder) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) TopChoiceAugment1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1Builder) TopChoiceAugment2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2Builder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Case11ChoiceCaseContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment2.augment.choice2.case11.Case11ChoiceCaseContainerBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 9 with TopBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder in project mdsal by opendaylight.

the class NormalizedNodeSerializeDeserializeTest method orderedLeafListFromNormalized.

@Test
public void orderedLeafListFromNormalized() {
    ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TOP_QNAME)).withChild(ImmutableUserLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME)).withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo")).withValue("foo").build()).build()).build();
    Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
    Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
    assertEquals(top, entry.getValue());
}
Also used : DataObject(org.opendaylight.yangtools.yang.binding.DataObject) TopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Test(org.junit.Test)

Example 10 with TopBuilder

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

the class Bug1125RegressionTest method writeInitialState.

private void writeInitialState() {
    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));
    assertCommit(initialTx.submit());
}
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)

Aggregations

TopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder)14 Test (org.junit.Test)13 Top (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top)8 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)7 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)5 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)5 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 TopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder)4 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)4 TopLevelList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList)3 TopLevelListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder)3 TopLevelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey)3 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)2 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)2 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)2 TreeComplexUsesAugment (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment)2