27d98c6cb72ae5d8a2a5ec0f3c6624773b525284
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug394Test.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 java.util.List;
15 import java.util.Set;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
22
23 /**
24  * Test antlr grammar capability to parse nested unknown nodes.
25  */
26 public class Bug394Test {
27
28     @Test
29     public void testParseList() throws Exception {
30         final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug394-retest").toURI());
31         final Module bug394 = TestUtils.findModule(modules, "bug394");
32         assertNotNull(bug394);
33         final Module bug394_ext = TestUtils.findModule(modules, "bug394-ext");
34         assertNotNull(bug394_ext);
35
36         final ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName(QName.create(
37                 bug394.getQNameModule(), "logrecords"));
38         assertNotNull(logrecords);
39
40         final List<UnknownSchemaNode> nodes = logrecords.getUnknownSchemaNodes();
41         assertEquals(2, nodes.size());
42
43         final List<ExtensionDefinition> extensions = bug394_ext.getExtensionSchemaNodes();
44         assertEquals(3, extensions.size());
45
46         assertTrue(extensions.contains(nodes.get(0).getExtensionDefinition()));
47         assertTrue(extensions.contains(nodes.get(1).getExtensionDefinition()));
48     }
49
50 }