2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.instanceOf;
11 import static org.hamcrest.CoreMatchers.startsWith;
12 import static org.hamcrest.MatcherAssert.assertThat;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
19 public class YT1410Test extends AbstractYangTest {
21 public void testRFC6020() {
22 assertInvalidSubstatementException(
23 startsWith("CHOICE is not valid for CHOICE. Error in module foo (QNameModule{ns=foo}) [at "),
24 "/bugs/YT1410/foo.yang");
28 public void testRFC7950() {
29 final var module = assertEffectiveModel("/bugs/YT1410/bar.yang").getModuleStatement(QName.create("bar", "bar"));
30 final var one = module.findSchemaTreeNode(QName.create("bar", "one")).orElseThrow();
31 assertThat(one, instanceOf(ChoiceEffectiveStatement.class));
32 final var two = ((ChoiceEffectiveStatement) one).findSchemaTreeNode(QName.create("bar", "two")).orElseThrow();
33 assertThat(two, instanceOf(CaseEffectiveStatement.class));
34 assertThat(((CaseEffectiveStatement) two).findSchemaTreeNode(QName.create("bar", "two")).orElseThrow(),
35 instanceOf(ChoiceEffectiveStatement.class));