2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 package org.opendaylight.yangtools.yang.stmt.retest;
6 import static org.junit.Assert.assertTrue;
8 import org.opendaylight.yangtools.yang.stmt.test.StmtTestUtils;
10 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
11 import java.net.URISyntaxException;
14 import org.junit.Ignore;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19 import org.opendaylight.yangtools.yang.model.api.UsesNode;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
21 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
23 public class AugmentToExtensionTest {
24 private Set<Module> modules;
26 @Test(expected = SomeModifiersUnresolvedException.class)
27 public void testIncorrectPath() throws URISyntaxException, SourceException, ReactorException {
28 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
33 * FIXME: Figure way to determine use case of tail-f:input without hacks
38 public void testCorrectPathIntoUnsupportedTarget() throws URISyntaxException, SourceException, ReactorException {
41 modules = TestUtils.loadModules(getClass().getResource(
42 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
43 } catch (Exception e) {
44 StmtTestUtils.log(e, " ");
48 Module devicesModule = TestUtils.findModule(modules, "augment-module");
50 ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName("my-container");
51 Set<UsesNode> uses = devicesContainer.getUses();
53 for (UsesNode usesNode : uses) {
54 assertTrue(usesNode.getAugmentations().isEmpty());
60 public void testCorrectAugment() throws URISyntaxException, SourceException, ReactorException {
61 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
63 Module devicesModule = TestUtils.findModule(modules, "augment-module");
65 ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName("my-container");
66 Set<UsesNode> uses = devicesContainer.getUses();
68 boolean augmentationIsInContainer = false;
69 for (UsesNode usesNode : uses) {
70 Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
71 for (AugmentationSchema augmentationSchema : augmentations) {
72 augmentationIsInContainer = true;
76 assertTrue(augmentationIsInContainer);