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.junit.Test;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.UsesNode;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
21 public class AugmentToExtensionTest {
22 private SchemaContext context;
24 @Test(expected = SomeModifiersUnresolvedException.class)
25 public void testIncorrectPath() throws Exception {
26 context = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
30 * FIXME: Figure way to determine use case of tail-f:input without hacks
33 public void testCorrectPathIntoUnsupportedTarget() throws Exception {
35 context = TestUtils.loadModules(getClass().getResource(
36 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
38 final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
39 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(
40 QName.create(devicesModule.getQNameModule(), "my-container"));
41 for (final UsesNode usesNode : devicesContainer.getUses()) {
42 assertTrue(usesNode.getAugmentations().isEmpty());
48 public void testCorrectAugment() throws Exception {
49 context = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
51 final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
53 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
54 .create(devicesModule.getQNameModule(), "my-container"));
55 boolean augmentationIsInContainer = false;
56 for (final UsesNode usesNode : devicesContainer.getUses()) {
57 for (final AugmentationSchemaNode augmentationSchema : usesNode.getAugmentations()) {
58 augmentationIsInContainer = true;
62 assertTrue(augmentationIsInContainer);