2 * Copyright (c) 2015 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.test;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
15 import org.junit.Test;
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.parser.spi.meta.ReactorException;
21 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
24 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
26 public class NotificationStmtTest {
28 private static final YangStatementSourceImpl NOTIFICATION_MODULE = new YangStatementSourceImpl("/model/baz.yang",
30 private static final YangStatementSourceImpl IMPORTED_MODULE = new YangStatementSourceImpl("/model/bar.yang",
34 public void notificationTest() throws ReactorException {
35 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
36 StmtTestUtils.addSources(reactor, NOTIFICATION_MODULE, IMPORTED_MODULE);
38 EffectiveSchemaContext result = reactor.buildEffective();
39 assertNotNull(result);
41 Module testModule = result.findModuleByName("baz", null);
42 assertNotNull(testModule);
44 Set<NotificationDefinition> notifications = testModule.getNotifications();
45 assertEquals(1, notifications.size());
47 NotificationDefinition notification = notifications.iterator().next();
48 assertEquals("event", notification.getQName().getLocalName());
49 assertEquals(3, notification.getChildNodes().size());
51 LeafSchemaNode leaf = (LeafSchemaNode) notification.getDataChildByName("event-class");
53 leaf = (LeafSchemaNode) notification.getDataChildByName("severity");
55 AnyXmlSchemaNode anyXml = (AnyXmlSchemaNode) notification.getDataChildByName("reporting-entity");
56 assertNotNull(anyXml);