Promote SchemaSourceRepresentation
[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.common.XMLNamespace;
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;
22
23 class MountTest {
24     private static final QNameModule FOO = QNameModule.create(XMLNamespace.of("foo"));
25
26     @Test
27     void test() throws Exception {
28         final var reactor = RFC7950Reactors.vanillaReactorBuilder()
29             .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
30                 new MountStatementSupport(YangParserConfiguration.DEFAULT))
31             .build();
32         final var foo = reactor.newBuild()
33             .addSource(YangStatementStreamSource.create(YangTextSource.forResource(MountTest.class, "/yang-ext.yang")))
34             .addSource(YangStatementStreamSource.create(YangTextSource.forResource(MountTest.class, "/mount.yang")))
35             .buildEffective()
36             .getModuleStatements()
37             .get(FOO);
38
39         assertTrue(foo.findDataTreeNode(QName.create(FOO, "foo")).orElseThrow()
40             .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
41             .isPresent());
42
43         assertTrue(foo.findDataTreeNode(QName.create(FOO, "bar")).orElseThrow()
44             .findFirstEffectiveSubstatement(MountEffectiveStatement.class)
45             .isPresent());
46     }
47 }