2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 package org.opendaylight.yangtools.yang.parser.impl;
6 import static org.junit.Assert.assertFalse;
7 import static org.junit.Assert.assertTrue;
9 import java.io.IOException;
10 import java.net.URISyntaxException;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
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.UsesNode;
18 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
20 public class AugmentToExtensionTest {
21 private Set<Module> modules;
23 @Test(expected = YangParseException.class)
24 public void testIncorrectPath() throws IOException, URISyntaxException {
25 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
30 public void testCorrectPathIntoUnsupportedTarget() throws IOException, URISyntaxException {
31 modules = TestUtils.loadModules(getClass().getResource(
32 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
34 Module devicesModul = TestUtils.findModule(modules, "augment-module");
36 ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModul.getDataChildByName("my-container");
37 Set<UsesNode> uses = devicesContainer.getUses();
39 boolean augmentationIsInContainer = false;
40 for (UsesNode usesNode : uses) {
41 Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
42 for (AugmentationSchema augmentationSchema : augmentations) {
43 augmentationIsInContainer = true;
47 assertFalse(augmentationIsInContainer);
51 public void testCorrectAugment() throws IOException, URISyntaxException {
52 modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
54 Module devicesModul = TestUtils.findModule(modules, "augment-module");
56 ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModul.getDataChildByName("my-container");
57 Set<UsesNode> uses = devicesContainer.getUses();
59 boolean augmentationIsInContainer = false;
60 for (UsesNode usesNode : uses) {
61 Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
62 for (AugmentationSchema augmentationSchema : augmentations) {
63 augmentationIsInContainer = true;
67 assertTrue(augmentationIsInContainer);