Search in sources :

Example 1 with UnkeyedBuilder

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder in project mdsal by opendaylight.

the class TestListSquashing method testUserOrderedList.

@Test
public void testUserOrderedList() {
    final Keyed keyed = new KeyedBuilder().withKey(new KeyedKey("a")).build();
    final Unkeyed unkeyed = new UnkeyedBuilder().build();
    final Container cont = new ContainerBuilder().setKeyed(List.of(keyed)).setUnkeyed(List.of(unkeyed)).build();
    // Non-empty Lists should be retained
    assertEquals(List.of(keyed), cont.getKeyed());
    assertEquals(List.of(unkeyed), cont.getUnkeyed());
}
Also used : Container(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container) KeyedBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.KeyedBuilder) ContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder) KeyedKey(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.KeyedKey) UnkeyedBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder) Keyed(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.Keyed) Unkeyed(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.Unkeyed) Test(org.junit.Test)

Example 2 with UnkeyedBuilder

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder in project mdsal by opendaylight.

the class Mdsal298Test method testUnkeyedDataTreeModification.

@Test
public void testUnkeyedDataTreeModification() throws InterruptedException, ExecutionException {
    final DataTreeChangeListener<Container> listener = assertWrittenContainer(Container.QNAME, Container.class, new ContainerBuilder().build());
    final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
    domTx.put(CONFIGURATION, YangInstanceIdentifier.create(CONTAINER_NID).node(Unkeyed.QNAME), Builders.unkeyedListBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo")).build()).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar")).build()).build());
    domTx.commit().get();
    final ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
    verify(listener).onDataTreeChanged(captor.capture());
    Collection<DataTreeModification<Container>> capture = captor.getValue();
    assertEquals(1, capture.size());
    final DataTreeModification<Container> change = capture.iterator().next();
    assertEquals(CONTAINER_TID, change.getRootPath());
    final DataObjectModification<Container> changedContainer = change.getRootNode();
    assertEquals(Item.of(Container.class), changedContainer.getIdentifier());
    assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
    final Container containerAfter = changedContainer.getDataAfter();
    assertEquals(new ContainerBuilder().setUnkeyed(List.of(new UnkeyedBuilder().setFoo("foo").build(), new UnkeyedBuilder().setFoo("bar").build())).build(), containerAfter);
    final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
    assertEquals(0, changedChildren.size());
}
Also used : DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) UnkeyedBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) Container(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container) ContainerBuilder(org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) Collection(java.util.Collection) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Container (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container)2 ContainerBuilder (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.ContainerBuilder)2 UnkeyedBuilder (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.UnkeyedBuilder)2 Collection (java.util.Collection)1 DataTreeModification (org.opendaylight.mdsal.binding.api.DataTreeModification)1 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)1 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)1 Keyed (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.Keyed)1 KeyedBuilder (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.KeyedBuilder)1 KeyedKey (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.KeyedKey)1 Unkeyed (org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.container.Unkeyed)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1