9b8e303b9300f65a64d1c8916216933376fecf0d
[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.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12
13 import java.util.Optional;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20
21 public class YT911Test {
22     private static final QName FOO = QName.create("foo", "2018-10-22", "foo");
23     private static final QName BAR = QName.create(FOO, "bar");
24
25     @Test
26     public void testAugmentationConfig() throws Exception {
27         final SchemaContext context = StmtTestUtils.parseYangSource("/bugs/YT911/foo.yang");
28         final DataSchemaNode foo = context.findDataChildByName(FOO).get();
29         assertEquals(Optional.of(Boolean.FALSE), foo.effectiveConfig());
30         assertTrue(foo instanceof ContainerSchemaNode);
31
32         // Instantiated node
33         final DataSchemaNode bar = ((ContainerSchemaNode) foo).findDataTreeChild(BAR).get();
34         assertEquals(Optional.of(Boolean.FALSE), bar.effectiveConfig());
35         assertTrue(foo instanceof ContainerSchemaNode);
36
37         // Original augmentation node
38         final AugmentationSchemaNode aug = ((ContainerSchemaNode) foo).getAvailableAugmentations().iterator().next();
39         final DataSchemaNode augBar = aug.findDataTreeChild(BAR).get();
40         assertEquals(Optional.empty(), augBar.effectiveConfig());
41         assertTrue(foo instanceof ContainerSchemaNode);
42     }
43 }