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.hamcrest.CoreMatchers.startsWith;
11 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.AugmentationSchemaNode;
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.UsesNode;
20 public class AugmentToExtensionTest extends AbstractYangTest {
22 public void testIncorrectPath() throws Exception {
23 assertInferenceExceptionDir("/augment-to-extension-test/incorrect-path",
24 startsWith("Augment target "
25 + "'Descendant{qnames=[(uri:augment-module?revision=2014-10-07)my-extension-name-a, input]}'"
26 + " not found [at "));
30 * FIXME: Figure way to determine use case of tail-f:input without hacks
33 public void testCorrectPathIntoUnsupportedTarget() throws Exception {
34 final Module devicesModule =
35 assertEffectiveModelDir("/augment-to-extension-test/correct-path-into-unsupported-target")
36 .findModules("augment-module").iterator().next();
37 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(
38 QName.create(devicesModule.getQNameModule(), "my-container"));
39 for (final UsesNode usesNode : devicesContainer.getUses()) {
40 assertTrue(usesNode.getAugmentations().isEmpty());
45 public void testCorrectAugment() throws Exception {
46 final Module devicesModule = assertEffectiveModelDir("/augment-to-extension-test/correct-augment")
47 .findModules("augment-module").iterator().next();
49 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
50 .create(devicesModule.getQNameModule(), "my-container"));
51 boolean augmentationIsInContainer = false;
52 for (final UsesNode usesNode : devicesContainer.getUses()) {
53 for (final AugmentationSchemaNode augmentationSchema : usesNode.getAugmentations()) {
54 augmentationIsInContainer = true;
58 assertTrue(augmentationIsInContainer);