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.common.XMLNamespace;
19 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
22 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
24 class Bug7038Test extends AbstractYangTest {
26 void unknownNodeTest() {
27 final var bar = assertEffectiveModelDir("/bugs/bug7038")
28 .getModuleStatement(QNameModule.create(XMLNamespace.of("bar"))).getDeclared();
29 final var decimal64 = bar.findFirstDeclaredSubstatement(UnrecognizedStatement.class).orElseThrow();
30 assertEquals("decimal64", decimal64.argument());
31 assertEquals(QName.create("foo", "decimal64"), decimal64.statementDefinition().getStatementName());
36 final var root = (ContainerSchemaNode) assertEffectiveModelDir("/bugs/bug7038/yang11")
37 .getDataChildByName(QName.create("foo", "root"));
38 final var typedef = ((LeafSchemaNode) root.getDataChildByName(QName.create("foo", "my-leafref")))
40 assertFalse(assertInstanceOf(LeafrefTypeDefinition.class, typedef).requireInstance());
45 assertInvalidSubstatementExceptionDir("/bugs/bug7038/yang10",
46 startsWith("REQUIRE_INSTANCE is not valid for TYPE"));