Search in sources :

Example 1 with ImmutableUnkeyedListNodeBuilder

use of org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder in project yangtools by opendaylight.

the class BuilderTest method immutableUnkeyedListNodeBuilderTest.

@Test
public void immutableUnkeyedListNodeBuilderTest() {
    final UnkeyedListEntryNode unkeyedListEntryNode = ImmutableUnkeyedListEntryNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LEAF).build();
    final ImmutableUnkeyedListNodeBuilder immutableUnkeyedListNodeBuilder = (ImmutableUnkeyedListNodeBuilder) ImmutableUnkeyedListNodeBuilder.create();
    final UnkeyedListNode unkeyedListNode = immutableUnkeyedListNodeBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).addChild(unkeyedListEntryNode).build();
    final UnkeyedListNode unkeyedListNodeSize = ImmutableUnkeyedListNodeBuilder.create(1).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).build();
    final UnkeyedListNode unkeyedListNodeCreated = ImmutableUnkeyedListNodeBuilder.create(unkeyedListNode).build();
    assertThrows(IndexOutOfBoundsException.class, () -> unkeyedListNodeSize.childAt(1));
    assertNotNull(unkeyedListNodeSize.body());
    assertEquals(unkeyedListEntryNode, unkeyedListNodeCreated.childAt(0));
    assertEquals(unkeyedListNode.getIdentifier(), unkeyedListNodeSize.getIdentifier());
    assertNotNull(unkeyedListNodeCreated);
}
Also used : ImmutableUnkeyedListNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)1 ImmutableUnkeyedListNodeBuilder (org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder)1