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