2 * Copyright (c) 2017 Cisco Systems, Inc. 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.yang.stmt;
10 import static org.hamcrest.CoreMatchers.startsWith;
11 import static org.junit.jupiter.api.Assertions.assertEquals;
12 import static org.junit.jupiter.api.Assertions.assertFalse;
13 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
15 import org.junit.jupiter.api.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
21 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
23 class Bug7038Test extends AbstractYangTest {
25 void unknownNodeTest() {
26 final var bar = assertEffectiveModelDir("/bugs/bug7038").getModuleStatement(QNameModule.of("bar"))
28 final var decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class).orElseThrow();
29 assertEquals("decimal64", decimal64.argument());
30 assertEquals(QName.create("foo", "decimal64"), decimal64.statementDefinition().getStatementName());
35 final var root = (ContainerSchemaNode) assertEffectiveModelDir("/bugs/bug7038/yang11")
36 .getDataChildByName(QName.create("foo", "root"));
37 final var typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
39 assertFalse(assertInstanceOf(LeafrefTypeDefinition.class, typedef).requireInstance());
44 assertInvalidSubstatementExceptionDir("/bugs/bug7038/yang10",
45 startsWith("REQUIRE_INSTANCE is not valid for TYPE"));