Further cleanup of tests
[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.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.util.Collection;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
20 import org.opendaylight.yangtools.yang.model.api.Submodule;
21
22 public class Bug3799Test extends AbstractYangTest {
23     @Test
24     public void test() {
25         final var schema = assertEffectiveModelDir("/bugs/bug3799");
26
27         Collection<? extends Module> modules = schema.getModules();
28         assertNotNull(modules);
29         assertEquals(1, modules.size());
30
31         Module testModule = modules.iterator().next();
32         Collection<? extends Submodule> subModules = testModule.getSubmodules();
33         assertNotNull(subModules);
34         assertEquals(1, subModules.size());
35
36         Submodule testSubmodule = subModules.iterator().next();
37
38         Collection<? extends NotificationDefinition> notifications = testSubmodule.getNotifications();
39         assertNotNull(notifications);
40         assertEquals(1, notifications.size());
41
42         NotificationDefinition bazNotification = notifications.iterator().next();
43         Collection<? extends DataSchemaNode> childNodes = bazNotification.getChildNodes();
44         assertNotNull(childNodes);
45         assertEquals(1, childNodes.size());
46
47         DataSchemaNode child = childNodes.iterator().next();
48         assertTrue(child instanceof LeafSchemaNode);
49
50         LeafSchemaNode leafBar = (LeafSchemaNode) child;
51         String bar = leafBar.getQName().getLocalName();
52         assertEquals("bar", bar);
53     }
54 }