Clean up TreeNode API
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YT911Test.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12
13 import java.util.Optional;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
17
18 class YT911Test extends AbstractYangTest {
19     private static final QName FOO = QName.create("foo", "2018-10-22", "foo");
20     private static final QName BAR = QName.create(FOO, "bar");
21
22     @Test
23     void testAugmentationConfig() {
24         final var context = assertEffectiveModel("/bugs/YT911/foo.yang");
25         final var foo = assertInstanceOf(ContainerSchemaNode.class, context.dataChildByName(FOO));
26         assertEquals(Optional.of(Boolean.FALSE), foo.effectiveConfig());
27
28         // Instantiated node
29         final var bar = foo.findDataTreeChild(BAR).orElseThrow();
30         assertEquals(Optional.of(Boolean.FALSE), bar.effectiveConfig());
31
32         // Original augmentation node
33         final var aug = foo.getAvailableAugmentations().iterator().next();
34         final var augBar = aug.findDataTreeChild(BAR).orElseThrow();
35         assertEquals(Optional.empty(), augBar.effectiveConfig());
36     }
37 }