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