Remove unneeded throws
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / NotificationStmtTest.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
13 import java.util.Collection;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
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
22 public class NotificationStmtTest {
23     @Test
24     public void notificationTest() throws Exception {
25         final SchemaContext result = TestUtils.parseYangSource("/model/baz.yang", "/model/bar.yang");
26         assertNotNull(result);
27
28         final Module testModule = result.findModules("baz").iterator().next();
29         assertNotNull(testModule);
30
31         final Collection<? extends NotificationDefinition> notifications = testModule.getNotifications();
32         assertEquals(1, notifications.size());
33
34         final NotificationDefinition notification = notifications.iterator().next();
35         assertEquals("event", notification.getQName().getLocalName());
36         assertEquals(3, notification.getChildNodes().size());
37
38         LeafSchemaNode leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(),
39                 "event-class"));
40         assertNotNull(leaf);
41         leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(), "severity"));
42         assertNotNull(leaf);
43         final AnyxmlSchemaNode anyXml = (AnyxmlSchemaNode) notification.getDataChildByName(QName.create(
44             testModule.getQNameModule(), "reporting-entity"));
45         assertNotNull(anyXml);
46     }
47 }