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