BUG-7052: move ModuleIdentifierImpl
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug3799Test.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.yangtools.yang.stmt;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
15 import java.util.Collection;
16 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
18 import java.util.Set;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
23 import java.io.IOException;
24 import java.net.URISyntaxException;
25 import org.junit.Test;
26
27 public class Bug3799Test {
28
29     @Test
30     public void test() throws IOException, URISyntaxException, SourceException,
31             ReactorException {
32         SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
33         assertNotNull(schema);
34
35         Set<Module> modules = schema.getModules();
36         assertNotNull(modules);
37         assertEquals(1, modules.size());
38
39         Module testModule = modules.iterator().next();
40         Set<Module> subModules = testModule.getSubmodules();
41         assertNotNull(subModules);
42         assertEquals(1, subModules.size());
43
44         Module testSubmodule = subModules.iterator().next();
45
46         Set<NotificationDefinition> notifications = testSubmodule
47                 .getNotifications();
48         assertNotNull(notifications);
49         assertEquals(1, notifications.size());
50
51         NotificationDefinition bazNotification = notifications.iterator()
52                 .next();
53         Collection<DataSchemaNode> childNodes = bazNotification.getChildNodes();
54         assertNotNull(childNodes);
55         assertEquals(1, childNodes.size());
56
57         DataSchemaNode child = childNodes.iterator().next();
58         assertTrue(child instanceof LeafSchemaNode);
59
60         LeafSchemaNode leafBar = (LeafSchemaNode) child;
61         String bar = leafBar.getQName().getLocalName();
62         assertEquals("bar", bar);
63     }
64
65 }