2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
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.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.Submodule;
23 public class Bug3799Test {
26 public void test() throws Exception {
27 SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
28 assertNotNull(schema);
30 Collection<? extends Module> modules = schema.getModules();
31 assertNotNull(modules);
32 assertEquals(1, modules.size());
34 Module testModule = modules.iterator().next();
35 Collection<? extends Submodule> subModules = testModule.getSubmodules();
36 assertNotNull(subModules);
37 assertEquals(1, subModules.size());
39 Submodule testSubmodule = subModules.iterator().next();
41 Collection<? extends NotificationDefinition> notifications = testSubmodule.getNotifications();
42 assertNotNull(notifications);
43 assertEquals(1, notifications.size());
45 NotificationDefinition bazNotification = notifications.iterator().next();
46 Collection<? extends DataSchemaNode> childNodes = bazNotification.getChildNodes();
47 assertNotNull(childNodes);
48 assertEquals(1, childNodes.size());
50 DataSchemaNode child = childNodes.iterator().next();
51 assertTrue(child instanceof LeafSchemaNode);
53 LeafSchemaNode leafBar = (LeafSchemaNode) child;
54 String bar = leafBar.getQName().getLocalName();
55 assertEquals("bar", bar);