Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug6669Test.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.assertNotNull;
11 import static org.junit.Assert.assertNull;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
22
23 public class Bug6669Test {
24     private static final String REV = "2016-09-08";
25     private static final String FOO_NS = "foo";
26     private static final String BAR_NS = "bar";
27     private static final QName ROOT = QName.create(FOO_NS, REV, "root");
28     private static final QName BAR = QName.create(BAR_NS, REV, "bar");
29     private static final QName BAR_1 = QName.create(BAR_NS, REV, "bar1");
30     private static final QName BAR_2 = QName.create(BAR_NS, REV, "bar2");
31     private static final QName M = QName.create(BAR_NS, REV, "m");
32     private static final QName L = QName.create(BAR_NS, REV, "l");
33
34     @Test
35     public void testInvalidAugment() throws Exception {
36         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test1");
37         assertNotNull(context);
38
39         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
40                 SchemaPath.create(true, ROOT, BAR, BAR_1, M));
41         assertNull(findDataSchemaNode);
42     }
43
44     @Test
45     public void testInvalidAugment2() throws Exception {
46         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test2");
47         assertNotNull(context);
48
49         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
50                 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, M));
51         assertNull(findDataSchemaNode);
52     }
53
54     @Test
55     public void testInvalidAugment3() throws Exception {
56         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/invalid/test3");
57         assertNotNull(context);
58
59         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
60                 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, L));
61         assertNull(findDataSchemaNode);
62     }
63
64     @Test
65     public void testValidAugment() throws Exception {
66         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test1");
67         assertNotNull(context);
68
69         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
70                 SchemaPath.create(true, ROOT, BAR, BAR_1, M));
71         assertTrue(findDataSchemaNode instanceof LeafSchemaNode);
72     }
73
74     @Test
75     public void testValidAugment2() throws Exception {
76         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test2");
77         assertNotNull(context);
78
79         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
80                 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, M));
81         assertTrue(findDataSchemaNode instanceof LeafSchemaNode);
82     }
83
84     @Test
85     public void testValidAugment3() throws Exception {
86         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6669/valid/test3");
87         assertNotNull(context);
88
89         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
90                 SchemaPath.create(true, ROOT, BAR, BAR_1, BAR_2, L));
91         assertTrue(findDataSchemaNode instanceof ListSchemaNode);
92     }
93 }