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;
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;
22 public class NotificationStmtTest {
24 public void notificationTest() throws Exception {
25 final SchemaContext result = TestUtils.parseYangSource("/model/baz.yang", "/model/bar.yang");
26 assertNotNull(result);
28 final Module testModule = result.findModules("baz").iterator().next();
29 assertNotNull(testModule);
31 final Collection<? extends NotificationDefinition> notifications = testModule.getNotifications();
32 assertEquals(1, notifications.size());
34 final NotificationDefinition notification = notifications.iterator().next();
35 assertEquals("event", notification.getQName().getLocalName());
36 assertEquals(3, notification.getChildNodes().size());
38 LeafSchemaNode leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(),
41 leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(), "severity"));
43 final AnyxmlSchemaNode anyXml = (AnyxmlSchemaNode) notification.getDataChildByName(QName.create(
44 testModule.getQNameModule(), "reporting-entity"));
45 assertNotNull(anyXml);