Fix javadoc formatting issues
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / AugmentToExtensionTest.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  */
4 package org.opendaylight.yangtools.yang.parser.impl;
5
6 import static org.junit.Assert.assertFalse;
7 import static org.junit.Assert.assertTrue;
8
9 import java.io.IOException;
10 import java.net.URISyntaxException;
11 import java.util.Set;
12
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;
19
20 public class AugmentToExtensionTest {
21     private Set<Module> modules;
22
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());
26
27     }
28
29     @Test
30     public void testCorrectPathIntoUnsupportedTarget() throws IOException, URISyntaxException {
31         modules = TestUtils.loadModules(getClass().getResource(
32                 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
33
34         Module devicesModul = TestUtils.findModule(modules, "augment-module");
35
36         ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModul.getDataChildByName("my-container");
37         Set<UsesNode> uses = devicesContainer.getUses();
38
39         boolean augmentationIsInContainer = false;
40         for (UsesNode usesNode : uses) {
41             Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
42             for (AugmentationSchema augmentationSchema : augmentations) {
43                 augmentationIsInContainer = true;
44             }
45         }
46
47         assertFalse(augmentationIsInContainer);
48     }
49
50     @Test
51     public void testCorrectAugment() throws IOException, URISyntaxException {
52         modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
53
54         Module devicesModul = TestUtils.findModule(modules, "augment-module");
55
56         ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModul.getDataChildByName("my-container");
57         Set<UsesNode> uses = devicesContainer.getUses();
58
59         boolean augmentationIsInContainer = false;
60         for (UsesNode usesNode : uses) {
61             Set<AugmentationSchema> augmentations = usesNode.getAugmentations();
62             for (AugmentationSchema augmentationSchema : augmentations) {
63                 augmentationIsInContainer = true;
64             }
65         }
66
67         assertTrue(augmentationIsInContainer);
68     }
69
70 }