Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug5101Test.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.assertEquals;
11 import static org.junit.Assert.assertNotNull;
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.ContainerSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 import org.opendaylight.yangtools.yang.model.api.Status;
21 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
22
23 public class Bug5101Test {
24     private static final String NS = "foo";
25     private static final String REV = "2016-01-29";
26
27     @Test
28     public void test() throws Exception {
29         SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5101");
30         assertNotNull(context);
31
32         QName grp = QName.create(NS, REV, "my-grouping");
33         QName myContainer = QName.create(NS, REV, "my-container");
34         QName root = QName.create(NS, REV, "root");
35
36         SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
37                 SchemaPath.create(true, grp, myContainer));
38         assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
39         ContainerSchemaNode myContainerInGrouping = (ContainerSchemaNode) findDataSchemaNode;
40         assertEquals(Status.DEPRECATED, myContainerInGrouping.getStatus());
41
42         findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, root, myContainer));
43         assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
44         ContainerSchemaNode myContainerInRoot = (ContainerSchemaNode) findDataSchemaNode;
45         assertEquals(Status.DEPRECATED, myContainerInRoot.getStatus());
46
47         findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, myContainer));
48         assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
49         ContainerSchemaNode myContainerInModule = (ContainerSchemaNode) findDataSchemaNode;
50         assertEquals(Status.DEPRECATED, myContainerInModule.getStatus());
51
52         findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, root));
53         assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
54         ContainerSchemaNode rootContainer = (ContainerSchemaNode) findDataSchemaNode;
55         assertEquals(Status.CURRENT, rootContainer.getStatus());
56     }
57 }