Replace calls of StmtTestUtils.parseYangSource(String) two
[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.Assert.assertEquals;
11 import static org.junit.Assert.assertNotSame;
12
13 import java.util.Optional;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
16 import org.opendaylight.yangtools.yang.common.XMLNamespace;
17 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
21
22 public class YT1312Test extends AbstractYangTest {
23     @Test
24     public void testRefineDefault() {
25         final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1312/foo.yang")
26             .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
27
28         final LeafListEffectiveStatement grpFoo = module
29             .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow()
30             .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
31         final LeafListEffectiveStatement foo = module
32             .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
33
34         assertNotSame(foo, grpFoo);
35         assertEquals(Optional.empty(), grpFoo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
36         assertEquals(Optional.of("abc"), foo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
37     }
38 }