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;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.common.Empty;
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.Module;
18 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
21 * Test ANTLR4 grammar capability to parse description statement in unknown node.
24 * Note: Everything under unknown node is unknown node.
26 public class Bug1412Test extends AbstractYangTest {
28 public void test() throws Exception {
29 final Module bug1412 = assertEffectiveModelDir("/bugs/bug1412").findModules("bug1412").iterator().next();
31 final ContainerSchemaNode node = (ContainerSchemaNode) bug1412.getDataChildByName(QName.create(
32 bug1412.getQNameModule(), "node"));
33 var unknownNodes = node.asEffectiveStatement().getDeclared().declaredSubstatements(UnrecognizedStatement.class);
34 assertEquals(1, unknownNodes.size());
35 final UnrecognizedStatement action = unknownNodes.iterator().next();
37 assertEquals(QName.create("urn:test:bug1412:ext:definitions", "2014-07-25", "action"),
38 action.statementDefinition().getStatementName());
39 assertEquals("hello", action.argument());
41 unknownNodes = action.declaredSubstatements(UnrecognizedStatement.class);
42 assertEquals(4, unknownNodes.size());
43 UnrecognizedStatement info = null;
44 UnrecognizedStatement description = null;
45 UnrecognizedStatement actionPoint = null;
46 UnrecognizedStatement output = null;
47 for (final UnrecognizedStatement un : unknownNodes) {
48 final String name = un.statementDefinition().getStatementName().getLocalName();
49 if ("info".equals(name)) {
51 } else if ("description".equals(name)) {
53 } else if ("actionpoint".equals(name)) {
55 } else if ("output".equals(name)) {
61 assertEquals(QName.create("urn:test:bug1412:ext:definitions", "2014-07-25", "info"),
62 info.statementDefinition().getStatementName());
63 assertEquals("greeting", info.argument());
65 assertNotNull(description);
66 assertEquals(QName.create("urn:test:bug1412:ext:definitions", "2014-07-25", "description"),
67 description.statementDefinition().getStatementName());
68 assertEquals("say greeting", description.argument());
70 assertNotNull(actionPoint);
71 assertEquals(QName.create("urn:test:bug1412:ext:definitions", "2014-07-25", "actionpoint"),
72 actionPoint.statementDefinition().getStatementName());
73 assertEquals("entry", actionPoint.argument());
75 assertNotNull(output);
76 assertEquals(QName.create("urn:test:bug1412:ext:definitions", "2014-07-25", "output"),
77 output.statementDefinition().getStatementName());
78 assertEquals(Empty.value(), output.argument());