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.yin;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
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;
28 public class YinFileLeafListStmtTest {
30 private SchemaContext context;
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());
39 public void testLeafList() {
40 final Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
41 assertNotNull(testModule);
43 ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
44 testModule.getQNameModule(), "netconf-state"));
45 assertNotNull(container);
47 container = (ContainerSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(),
49 assertNotNull(container);
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());