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;
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.model.api.stmt.CaseEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
20 class YT1410Test extends AbstractYangTest {
23 assertInvalidSubstatementException(
24 startsWith("CHOICE is not valid for CHOICE. Error in module foo (QNameModule{ns=foo}) [at "),
25 "/bugs/YT1410/foo.yang");
30 final var module = assertEffectiveModel("/bugs/YT1410/bar.yang").getModuleStatement(QName.create("bar", "bar"));
31 final var one = module.findSchemaTreeNode(QName.create("bar", "one")).orElseThrow();
32 assertInstanceOf(ChoiceEffectiveStatement.class, one);
33 final var two = ((ChoiceEffectiveStatement) one).findSchemaTreeNode(QName.create("bar", "two")).orElseThrow();
34 assertInstanceOf(CaseEffectiveStatement.class, two);
35 assertThat(((CaseEffectiveStatement) two).findSchemaTreeNode(QName.create("bar", "two")).orElseThrow(),
36 instanceOf(ChoiceEffectiveStatement.class));