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.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import java.net.URISyntaxException;
15 import java.util.Iterator;
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.AugmentationSchema;
21 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
22 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.model.api.UsesNode;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
26 import org.opendaylight.yangtools.yang.stmt.TestUtils;
28 public class YinFileUsesStmtTest {
30 private Set<Module> modules;
33 public void init() throws URISyntaxException, ReactorException {
34 modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
35 assertEquals(9, modules.size());
39 public void testUses() {
40 final Module testModule = TestUtils.findModule(modules, "main-impl");
41 assertNotNull(testModule);
43 final Set<AugmentationSchema> augmentations = testModule.getAugmentations();
44 assertEquals(1, augmentations.size());
46 final Iterator<AugmentationSchema> augmentIterator = augmentations.iterator();
47 final AugmentationSchema augment = augmentIterator.next();
49 final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(QName.create(testModule.getQNameModule(),
51 assertNotNull(caseNode);
53 final ContainerSchemaNode container = (ContainerSchemaNode) caseNode.getDataChildByName(QName.create(
54 testModule.getQNameModule(), "notification-service"));
55 assertNotNull(container);
57 assertEquals(1, container.getUses().size());
58 final UsesNode usesNode = container.getUses().iterator().next();
59 assertNotNull(usesNode);
64 "[(urn:opendaylight:params:xml:ns:yang:controller:" + "config?revision=2013-04-05)service-ref]"));
65 assertEquals(1, usesNode.getRefines().size());