X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FNotificationStmtTest.java;fp=yang%2Fyang-parser-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FNotificationStmtTest.java;h=8918f44d62d548df4475d1a741d904b4d24f4432;hb=c3ff09884178e03dc325b75b0944fd8239319058;hp=0000000000000000000000000000000000000000;hpb=abced3230f02588c577c17c0cc039c5707c85081;p=yangtools.git diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/NotificationStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/NotificationStmtTest.java new file mode 100644 index 0000000000..8918f44d62 --- /dev/null +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/NotificationStmtTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.yangtools.yang.stmt; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.Set; +import org.junit.Test; +import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; +import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; +import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; +import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext; + +public class NotificationStmtTest { + + private static final YangStatementSourceImpl NOTIFICATION_MODULE = new YangStatementSourceImpl("/model/baz.yang", + false); + private static final YangStatementSourceImpl IMPORTED_MODULE = new YangStatementSourceImpl("/model/bar.yang", + false); + + @Test + public void notificationTest() throws ReactorException { + CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + StmtTestUtils.addSources(reactor, NOTIFICATION_MODULE, IMPORTED_MODULE); + + EffectiveSchemaContext result = reactor.buildEffective(); + assertNotNull(result); + + Module testModule = result.findModuleByName("baz", null); + assertNotNull(testModule); + + Set notifications = testModule.getNotifications(); + assertEquals(1, notifications.size()); + + NotificationDefinition notification = notifications.iterator().next(); + assertEquals("event", notification.getQName().getLocalName()); + assertEquals(3, notification.getChildNodes().size()); + + LeafSchemaNode leaf = (LeafSchemaNode) notification.getDataChildByName("event-class"); + assertNotNull(leaf); + leaf = (LeafSchemaNode) notification.getDataChildByName("severity"); + assertNotNull(leaf); + AnyXmlSchemaNode anyXml = (AnyXmlSchemaNode) notification.getDataChildByName("reporting-entity"); + assertNotNull(anyXml); + } +}