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
9 package org.opendaylight.yangtools.yang.stmt;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
15 import java.util.Collection;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
22 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
24 public class Bug3799Test {
27 public void test() throws Exception {
28 SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
29 assertNotNull(schema);
31 Set<Module> modules = schema.getModules();
32 assertNotNull(modules);
33 assertEquals(1, modules.size());
35 Module testModule = modules.iterator().next();
36 Set<Module> subModules = testModule.getSubmodules();
37 assertNotNull(subModules);
38 assertEquals(1, subModules.size());
40 Module testSubmodule = subModules.iterator().next();
42 Set<NotificationDefinition> notifications = testSubmodule
44 assertNotNull(notifications);
45 assertEquals(1, notifications.size());
47 NotificationDefinition bazNotification = notifications.iterator()
49 Collection<DataSchemaNode> childNodes = bazNotification.getChildNodes();
50 assertNotNull(childNodes);
51 assertEquals(1, childNodes.size());
53 DataSchemaNode child = childNodes.iterator().next();
54 assertTrue(child instanceof LeafSchemaNode);
56 LeafSchemaNode leafBar = (LeafSchemaNode) child;
57 String bar = leafBar.getQName().getLocalName();
58 assertEquals("bar", bar);