Define a feature-parent
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / YT1312Test.java
1 /*
2  * Copyright (c) 2021 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.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertNotSame;
12
13 import java.util.Optional;
14 import org.junit.jupiter.api.Test;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
16 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
19
20 class YT1312Test extends AbstractYangTest {
21     @Test
22     void testRefineDefault() {
23         final var module = assertEffectiveModel("/bugs/YT1312/foo.yang").getModuleStatement(QNameModule.of("foo"));
24
25         final LeafListEffectiveStatement grpFoo = module
26             .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
27             .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
28         final LeafListEffectiveStatement foo = module
29             .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
30
31         assertNotSame(foo, grpFoo);
32         assertEquals(Optional.empty(), grpFoo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
33         assertEquals(Optional.of("abc"), foo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
34     }
35 }