Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileLeafListStmtTest.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.yin;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13
14 import java.io.IOException;
15 import java.net.URISyntaxException;
16 import java.util.Optional;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
25 import org.opendaylight.yangtools.yang.stmt.TestUtils;
26 import org.xml.sax.SAXException;
27
28 public class YinFileLeafListStmtTest {
29
30     private SchemaContext context;
31
32     @Before
33     public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
34         context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
35         assertEquals(9, context.getModules().size());
36     }
37
38     @Test
39     public void testLeafList() {
40         final Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
41         assertNotNull(testModule);
42
43         ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
44                 testModule.getQNameModule(), "netconf-state"));
45         assertNotNull(container);
46
47         container = (ContainerSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(),
48                 "capabilities"));
49         assertNotNull(container);
50
51         final LeafListSchemaNode leafList = (LeafListSchemaNode) container.getDataChildByName(QName.create(
52                 testModule.getQNameModule(), "capability"));
53         assertNotNull(leafList);
54         assertEquals("uri", leafList.getType().getQName().getLocalName());
55         assertEquals(Optional.of("List of NETCONF capabilities supported by the server."), leafList.getDescription());
56         assertFalse(leafList.isUserOrdered());
57     }
58 }