2 * Copyright (c) 2017 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 java.util.Collection;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
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 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
22 public class Bug7865Test {
23 private static final String NS = "foo";
26 public void test() throws Exception {
27 final SchemaContext context = TestUtils.parseYangSources("/bugs/bug7865");
28 assertNotNull(context);
30 final DataSchemaNode root = context.getDataChildByName(foo("root"));
31 assertTrue(root instanceof ContainerSchemaNode);
32 final Collection<? extends UnrecognizedStatement> unknownSchemaNodes = ((ContainerSchemaNode) root)
33 .asEffectiveStatement().getDeclared().declaredSubstatements(UnrecognizedStatement.class);
34 assertEquals(1, unknownSchemaNodes.size());
36 final UnrecognizedStatement unknownNode = unknownSchemaNodes.iterator().next();
37 final Collection<? extends UnrecognizedStatement> subUnknownSchemaNodes =
38 unknownNode.declaredSubstatements(UnrecognizedStatement.class);
39 assertEquals(1, subUnknownSchemaNodes.size());
41 final UnrecognizedStatement subUnknownNode = subUnknownSchemaNodes.iterator().next();
42 final Collection<? extends UnrecognizedStatement> subSubUnknownSchemaNodes =
43 subUnknownNode.declaredSubstatements(UnrecognizedStatement.class);
44 assertEquals(1, subSubUnknownSchemaNodes.size());
46 assertEquals("p", subSubUnknownSchemaNodes.iterator().next().argument());
49 private static QName foo(final String localName) {
50 return QName.create(NS, localName);