2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.impl.schema;
10 import org.junit.jupiter.api.Test;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.common.XMLNamespace;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
17 class NormalizedDataBuilderTest {
19 void testSchemaUnaware() {
21 final var builder = Builders.containerBuilder()
22 .withNodeIdentifier(getNodeIdentifier("container"))
23 .withChild(Builders.<String>leafBuilder()
24 .withNodeIdentifier(getNodeIdentifier("leaf"))
27 .withChild(Builders.<Integer>leafSetBuilder()
28 .withNodeIdentifier(getNodeIdentifier("leaf"))
30 .withChild(Builders.<Integer>leafSetEntryBuilder()
31 .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3))
35 .withChild(Builders.mapBuilder()
36 .withNodeIdentifier(getNodeIdentifier("list"))
37 .withChild(Builders.mapEntryBuilder()
38 .withChild(Builders.<Integer>leafBuilder()
39 .withNodeIdentifier(getNodeIdentifier("uint32InList"))
42 .withChild(Builders.containerBuilder()
43 .withNodeIdentifier(getNodeIdentifier("containerInList"))
45 .withNodeIdentifier(NodeIdentifierWithPredicates.of(getNodeIdentifier("list").getNodeType(),
46 getNodeIdentifier("uint32InList").getNodeType(), 1))
49 .withChild(Builders.<Integer>leafBuilder()
50 .withNodeIdentifier(getNodeIdentifier("augmentUint32"))
54 // This works without schema (adding child from augment as a direct child)
55 builder.withChild(Builders.<Integer>leafBuilder()
56 .withNodeIdentifier(getNodeIdentifier("augmentUint32"))
61 private static <T> NodeWithValue<T> getNodeWithValueIdentifier(final String localName, final T value) {
62 return new NodeWithValue<>(getQName(localName), value);
65 private static QName getQName(final String localName) {
66 return QName.create(XMLNamespace.of("namespace"), localName);
69 private static NodeIdentifier getNodeIdentifier(final String localName) {
70 return new NodeIdentifier(getQName(localName));