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.io.IOException;
15 import java.net.URISyntaxException;
16 import java.util.Iterator;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
22 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
26 import org.opendaylight.yangtools.yang.stmt.TestUtils;
27 import org.xml.sax.SAXException;
29 public class YinFileAugmentStmtTest {
31 private SchemaContext context;
34 public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
35 context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
36 assertEquals(9, context.getModules().size());
40 public void testAugment() {
41 final Module testModule = TestUtils.findModule(context, "main-impl").get();
42 assertNotNull(testModule);
44 final Set<AugmentationSchema> augmentations = testModule.getAugmentations();
45 assertEquals(1, augmentations.size());
47 final Iterator<AugmentationSchema> augmentIterator = augmentations.iterator();
48 final AugmentationSchema augment = augmentIterator.next();
49 assertNotNull(augment);
50 assertTrue(augment.getTargetPath().toString().contains(
51 "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, "
52 + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, "
53 + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration"));
55 assertEquals(1, augment.getChildNodes().size());
56 final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(QName.create(
57 testModule.getQNameModule(), "main-impl"));
58 assertNotNull(caseNode);