Address FIXME for QueuedNotificationManager
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / test / yin / YinFileUsesStmtTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.stmt.test.yin;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.net.URISyntaxException;
15 import java.util.Iterator;
16 import java.util.Set;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
20 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
21 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.model.api.UsesNode;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
25 import org.opendaylight.yangtools.yang.stmt.retest.TestUtils;
26
27 public class YinFileUsesStmtTest {
28
29     private Set<Module> modules;
30
31     @Before
32     public void init() throws URISyntaxException, ReactorException {
33         modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
34         assertEquals(9, modules.size());
35     }
36
37     @Test
38     public void testUses() {
39         Module testModule = TestUtils.findModule(modules, "main-impl");
40         assertNotNull(testModule);
41
42         Set<AugmentationSchema> augmentations = testModule.getAugmentations();
43         assertEquals(1, augmentations.size());
44
45         Iterator<AugmentationSchema> augmentIterator = augmentations.iterator();
46         AugmentationSchema augment = augmentIterator.next();
47
48         ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName("main-impl");
49         assertNotNull(caseNode);
50
51         ContainerSchemaNode container = (ContainerSchemaNode) caseNode.getDataChildByName("notification-service");
52         assertNotNull(container);
53
54         assertEquals(1, container.getUses().size());
55         UsesNode usesNode = container.getUses().iterator().next();
56         assertNotNull(usesNode);
57         assertTrue(usesNode.getGroupingPath().toString().contains("[(urn:opendaylight:params:xml:ns:yang:controller:" +
58                 "config?revision=2013-04-05)service-ref]"));
59         assertEquals(1, usesNode.getRefines().size());
60     }
61 }