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;
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;
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;
27 public class Bug3799Test {
30 public void test() throws IOException, URISyntaxException, SourceException,
32 SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug3799");
33 assertNotNull(schema);
35 Set<Module> modules = schema.getModules();
36 assertNotNull(modules);
37 assertEquals(1, modules.size());
39 Module testModule = modules.iterator().next();
40 Set<Module> subModules = testModule.getSubmodules();
41 assertNotNull(subModules);
42 assertEquals(1, subModules.size());
44 Module testSubmodule = subModules.iterator().next();
46 Set<NotificationDefinition> notifications = testSubmodule
48 assertNotNull(notifications);
49 assertEquals(1, notifications.size());
51 NotificationDefinition bazNotification = notifications.iterator()
53 Collection<DataSchemaNode> childNodes = bazNotification.getChildNodes();
54 assertNotNull(childNodes);
55 assertEquals(1, childNodes.size());
57 DataSchemaNode child = childNodes.iterator().next();
58 assertTrue(child instanceof LeafSchemaNode);
60 LeafSchemaNode leafBar = (LeafSchemaNode) child;
61 String bar = leafBar.getQName().getLocalName();
62 assertEquals("bar", bar);