Search in sources :

Example 1 with UnmodifiableCollection

use of org.opendaylight.yangtools.util.UnmodifiableCollection in project yangtools by opendaylight.

the class BuilderTest method immutableUserLeafSetNodeBuilderTest.

@Test
public void immutableUserLeafSetNodeBuilderTest() {
    final UserLeafSetNode<String> orderedLeafSet = ImmutableUserLeafSetNodeBuilder.<String>create().withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).withChild(LEAF_SET_ENTRY_NODE).withChildValue("baz").removeChild(BAR_PATH).build();
    final LinkedList<LeafSetNode<?>> mapEntryNodeColl = new LinkedList<>();
    mapEntryNodeColl.add(orderedLeafSet);
    final UnmodifiableCollection<?> leafSetCollection = (UnmodifiableCollection<?>) orderedLeafSet.body();
    final NormalizedNode orderedMapNodeSchemaAware = ImmutableUserLeafSetNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).withChildValue("baz").build();
    final UnmodifiableCollection<?> SchemaAwareleafSetCollection = (UnmodifiableCollection<?>) orderedMapNodeSchemaAware.body();
    assertNotNull(Builders.anyXmlBuilder());
    assertEquals(1, ((UserLeafSetNode<?>) orderedLeafSet).size());
    assertEquals("baz", orderedLeafSet.childAt(0).body());
    assertNull(orderedLeafSet.childByArg(BAR_PATH));
    assertEquals(1, leafSetCollection.size());
    assertEquals(1, SchemaAwareleafSetCollection.size());
}
Also used : NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) UserLeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode) SystemLeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode) LeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode) LinkedList(java.util.LinkedList) UnmodifiableCollection(org.opendaylight.yangtools.util.UnmodifiableCollection) Test(org.junit.Test)

Aggregations

LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1 UnmodifiableCollection (org.opendaylight.yangtools.util.UnmodifiableCollection)1 LeafSetNode (org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1 SystemLeafSetNode (org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode)1 UserLeafSetNode (org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode)1