Fix if-feature propagation for implicit case statements
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YT1431Test.java
1 /*
2  * Copyright (c) 2022 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.Assert.assertEquals;
11
12 import java.util.List;
13 import java.util.Set;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
18
19 public class YT1431Test {
20     @Test
21     public void testUnsupportedChoiceLeaf() throws Exception {
22         final var module = StmtTestUtils.parseYangSource("/bugs/YT1431/foo.yang", Set.of())
23             .findModuleStatement(QName.create("foo", "foo"))
24             .orElseThrow();
25         final var choice = module.findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow();
26         assertEquals(List.of(), choice.effectiveSubstatements());
27     }
28
29     @Test
30     public void testUnsupportedChoiceLeafAugment() throws Exception {
31         final var module = StmtTestUtils.parseYangSource("/bugs/YT1431/bar.yang", Set.of())
32             .findModuleStatement(QName.create("bar", "bar"))
33             .orElseThrow();
34         final var choice = module.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow()
35             .findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class)
36             .orElseThrow();
37         assertEquals(List.of(), choice.effectiveSubstatements());
38     }
39 }