Migrate users of deprecated QNameModule methods
[yangtools.git] / parser / odlext-parser-support / src / test / java / org / opendaylight / yangtools / odlext / parser / MountTest.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.odlext.parser;
9
10 import static org.junit.jupiter.api.Assertions.assertTrue;
11
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;
21
22 class MountTest {
23     private static final QNameModule FOO = QNameModule.of("foo");
24
25     @Test
26     void test() throws Exception {
27         final var reactor = RFC7950Reactors.vanillaReactorBuilder()
28             .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
29                 new MountStatementSupport(YangParserConfiguration.DEFAULT))
30             .build();
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"))))
36             .buildEffective()
37             .getModuleStatements()
38             .get(FOO);
39
40         assertTrue(foo.findDataTreeNode(QName.create(FOO, "foo")).orElseThrow()
41             .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
42             .isPresent());
43
44         assertTrue(foo.findDataTreeNode(QName.create(FOO, "bar")).orElseThrow()
45             .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
46             .isPresent());
47     }
48 }