2 * Copyright (c) 2021 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.odlext.parser;
10 import static org.junit.jupiter.api.Assertions.assertTrue;
12 import org.junit.jupiter.api.Test;
13 import org.opendaylight.yangtools.odlext.model.api.MountEffectiveStatement;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
16 import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
17 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
18 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
23 private static final QNameModule FOO = QNameModule.of("foo");
26 void test() throws Exception {
27 final var reactor = RFC7950Reactors.vanillaReactorBuilder()
28 .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
29 new MountStatementSupport(YangParserConfiguration.DEFAULT))
31 final var foo = reactor.newBuild()
32 .addSource(YangStatementStreamSource.create(new URLYangTextSource(
33 MountTest.class.getResource("/yang-ext.yang"))))
34 .addSource(YangStatementStreamSource.create(new URLYangTextSource(
35 MountTest.class.getResource("/mount.yang"))))
37 .getModuleStatements()
40 assertTrue(foo.findDataTreeNode(QName.create(FOO, "foo")).orElseThrow()
41 .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
44 assertTrue(foo.findDataTreeNode(QName.create(FOO, "bar")).orElseThrow()
45 .findFirstEffectiveSubstatement(MountEffectiveStatement.class)