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.model.api.AugmentationSchema;
20 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
23 import org.opendaylight.yangtools.yang.stmt.TestUtils;
25 public class YinFileAugmentStmtTest {
27 private Set<Module> modules;
30 public void init() throws URISyntaxException, ReactorException {
31 modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
32 assertEquals(9, modules.size());
36 public void testAugment() {
37 Module testModule = TestUtils.findModule(modules, "main-impl");
38 assertNotNull(testModule);
40 Set<AugmentationSchema> augmentations = testModule.getAugmentations();
41 assertEquals(1, augmentations.size());
43 Iterator<AugmentationSchema> augmentIterator = augmentations.iterator();
44 AugmentationSchema augment = augmentIterator.next();
45 assertNotNull(augment);
46 assertTrue(augment.getTargetPath().toString().contains(
47 "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, " +
48 "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, " +
49 "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration"));
51 assertEquals(1, augment.getChildNodes().size());
52 ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName("main-impl");
53 assertNotNull(caseNode);