Clean up TreeNode API
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YT859Test.java
1 /*
2  * Copyright (c) 2020 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.yang.stmt;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
12 import static org.junit.jupiter.api.Assertions.assertNull;
13
14 import com.google.common.collect.Iterables;
15 import java.util.Set;
16 import org.junit.jupiter.api.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
22
23 class YT859Test {
24     @Test
25     void testAugmentUnsupported() throws Exception {
26         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/YT859/", Set.of(),
27             YangParserConfiguration.DEFAULT);
28         assertEquals(4, context.getModules().size());
29
30         final DataSchemaNode named = Iterables.getOnlyElement(context.findModules("xyzzy"))
31             .findDataChildByName(QName.create("xyzzy", "xyzzy"), QName.create("xyzzy", "named")).orElseThrow();
32         assertNull(assertInstanceOf(ListSchemaNode.class, named).dataChildByName(QName.create("foo", "foo")));
33     }
34 }