2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
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;
23 public class Bug5101Test {
24 private static final String NS = "foo";
25 private static final String REV = "2016-01-29";
28 public void test() throws Exception {
29 SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5101");
30 assertNotNull(context);
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");
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());
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());
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());
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());