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
35 public void testCorrectPathIntoUnsupportedTarget() throws Exception {
38 context = TestUtils.loadModules(getClass().getResource(
39 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
40 } catch (final Exception e) {
41 StmtTestUtils.log(e, " ");
45 final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
47 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
48 .create(devicesModule.getQNameModule(), "my-container"));
49 final Set<UsesNode> uses = devicesContainer.getUses();
51 for (final UsesNode usesNode : uses) {
52 assertTrue(usesNode.getAugmentations().isEmpty());
58 public void testCorrectAugment() throws Exception {
59 context = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
61 final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
63 final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
64 .create(devicesModule.getQNameModule(), "my-container"));
65 final Set<UsesNode> uses = devicesContainer.getUses();
67 boolean augmentationIsInContainer = false;
68 for (final UsesNode usesNode : uses) {
69 final Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
70 for (final AugmentationSchema augmentationSchema : augmentations) {
71 augmentationIsInContainer = true;
75 assertTrue(augmentationIsInContainer);