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 org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
13 import java.net.URISyntaxException;
16 import org.junit.Ignore;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
19 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.UsesNode;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
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 (Exception e) {
46 StmtTestUtils.log(e, " ");
50 Module devicesModule = TestUtils.findModule(modules, "augment-module");
52 ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName("my-container");
53 Set<UsesNode> uses = devicesContainer.getUses();
55 for (UsesNode usesNode : uses) {
56 assertTrue(usesNode.getAugmentations().isEmpty());
62 public void testCorrectAugment() throws URISyntaxException, SourceException, ReactorException {
63 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
65 Module devicesModule = TestUtils.findModule(modules, "augment-module");
67 ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName("my-container");
68 Set<UsesNode> uses = devicesContainer.getUses();
70 boolean augmentationIsInContainer = false;
71 for (UsesNode usesNode : uses) {
72 Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
73 for (AugmentationSchema augmentationSchema : augmentations) {
74 augmentationIsInContainer = true;
78 assertTrue(augmentationIsInContainer);