2 * Copyright (c) 2019 PANTHEON.tech s.r.o. 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.rfc8639.parser;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertTrue;
13 import org.junit.jupiter.api.Test;
14 import org.opendaylight.yangtools.rfc8639.model.api.SubscribedNotificationsConstants;
15 import org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.spi.source.YangTextSource;
18 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
23 class SubscribedNotificationsTest {
25 void testSubscribedNotifications() throws Exception {
26 final var reactor = RFC7950Reactors.vanillaReactorBuilder()
27 .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
28 new SubscriptionStateNotificationStatementSupport(YangParserConfiguration.DEFAULT))
31 final var context = reactor.newBuild()
33 YangStatementStreamSource.create(YangTextSource.forResource(
34 SubscribedNotificationsTest.class, "/ietf-inet-types@2013-07-15.yang")),
35 YangStatementStreamSource.create(YangTextSource.forResource(
36 SubscribedNotificationsTest.class, "/ietf-interfaces@2018-02-20.yang")),
37 YangStatementStreamSource.create(YangTextSource.forResource(
38 SubscribedNotificationsTest.class, "/ietf-ip@2018-02-22.yang")),
39 YangStatementStreamSource.create(YangTextSource.forResource(
40 SubscribedNotificationsTest.class, "/ietf-netconf-acm@2018-02-14.yang")),
41 YangStatementStreamSource.create(YangTextSource.forResource(
42 SubscribedNotificationsTest.class, "/ietf-network-instance@2019-01-21.yang")),
43 YangStatementStreamSource.create(YangTextSource.forResource(
44 SubscribedNotificationsTest.class, "/ietf-restconf@2017-01-26.yang")),
45 YangStatementStreamSource.create(YangTextSource.forResource(
46 SubscribedNotificationsTest.class, "/ietf-yang-schema-mount@2019-01-14.yang")),
47 YangStatementStreamSource.create(YangTextSource.forResource(
48 SubscribedNotificationsTest.class, "/ietf-yang-types@2013-07-15.yang")))
50 YangStatementStreamSource.create(YangTextSource.forResource(
51 SubscribedNotificationsTest.class, "/ietf-subscribed-notifications@2019-09-09.yang")))
54 final var notifications = context.getModuleStatement(SubscribedNotificationsConstants.RFC8639_MODULE)
55 .streamEffectiveSubstatements(NotificationEffectiveStatement.class)
58 assertEquals(7, notifications.size());
59 for (var notif : notifications) {
60 final var sub = notif.findFirstEffectiveSubstatement(SubscriptionStateNotificationEffectiveStatement.class);
61 assertTrue(sub.isPresent(), "No marker in " + notif.argument());