Clean up TreeNode API
[yangtools.git] / parser / yang-parser-rfc7950 / 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 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertNotNull;
13
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
18 import org.opendaylight.yangtools.yang.model.api.Submodule;
19
20 class Bug3799Test extends AbstractYangTest {
21     @Test
22     void test() {
23         final var schema = assertEffectiveModelDir("/bugs/bug3799");
24
25         var modules = schema.getModules();
26         assertNotNull(modules);
27         assertEquals(1, modules.size());
28
29         Module testModule = modules.iterator().next();
30         var subModules = testModule.getSubmodules();
31         assertNotNull(subModules);
32         assertEquals(1, subModules.size());
33
34         Submodule testSubmodule = subModules.iterator().next();
35
36         var notifications = testSubmodule.getNotifications();
37         assertNotNull(notifications);
38         assertEquals(1, notifications.size());
39
40         NotificationDefinition bazNotification = notifications.iterator().next();
41         var childNodes = bazNotification.getChildNodes();
42         assertNotNull(childNodes);
43         assertEquals(1, childNodes.size());
44
45         LeafSchemaNode leafBar = assertInstanceOf(LeafSchemaNode.class, childNodes.iterator().next());
46         assertEquals("bar", leafBar.getQName().getLocalName());
47     }
48 }