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;
10 import static org.junit.Assert.assertTrue;
12 import java.net.URISyntaxException;
14 import org.junit.Ignore;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.UsesNode;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
25 public class AugmentToExtensionTest {
26 private Set<Module> modules;
28 @Test(expected = SomeModifiersUnresolvedException.class)
29 public void testIncorrectPath() throws URISyntaxException, SourceException, ReactorException {
30 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
35 * FIXME: Figure way to determine use case of tail-f:input without hacks
40 public void testCorrectPathIntoUnsupportedTarget() throws URISyntaxException, SourceException, ReactorException {
43 modules = TestUtils.loadModules(getClass().getResource(
44 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
45 } catch (final Exception e) {
46 StmtTestUtils.log(e, " ");
50 final Module devicesModule = TestUtils.findModule(modules, "augment-module");
52 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
53 .create(devicesModule.getQNameModule(), "my-container"));
54 final Set<UsesNode> uses = devicesContainer.getUses();
56 for (final UsesNode usesNode : uses) {
57 assertTrue(usesNode.getAugmentations().isEmpty());
63 public void testCorrectAugment() throws URISyntaxException, SourceException, ReactorException {
64 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
66 final Module devicesModule = TestUtils.findModule(modules, "augment-module");
68 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
69 .create(devicesModule.getQNameModule(), "my-container"));
70 final Set<UsesNode> uses = devicesContainer.getUses();
72 boolean augmentationIsInContainer = false;
73 for (final UsesNode usesNode : uses) {
74 final Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
75 for (final AugmentationSchema augmentationSchema : augmentations) {
76 augmentationIsInContainer = true;
80 assertTrue(augmentationIsInContainer);