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.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
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;
23 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
26 public class NotificationStmtTest {
29 public void notificationTest() throws ReactorException {
30 final SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
31 .addSources(sourceForResource("/model/baz.yang"), sourceForResource("/model/bar.yang"))
33 assertNotNull(result);
35 final Module testModule = result.findModules("baz").iterator().next();
36 assertNotNull(testModule);
38 final Set<NotificationDefinition> notifications = testModule.getNotifications();
39 assertEquals(1, notifications.size());
41 final NotificationDefinition notification = notifications.iterator().next();
42 assertEquals("event", notification.getQName().getLocalName());
43 assertEquals(3, notification.getChildNodes().size());
45 LeafSchemaNode leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(),
48 leaf = (LeafSchemaNode) notification.getDataChildByName(QName.create(testModule.getQNameModule(), "severity"));
50 final AnyxmlSchemaNode anyXml = (AnyxmlSchemaNode) notification.getDataChildByName(QName.create(
51 testModule.getQNameModule(), "reporting-entity"));
52 assertNotNull(anyXml);