X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-rfc7950%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FYT1312Test.java;fp=yang%2Fyang-parser-rfc7950%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FYT1312Test.java;h=8723e272a3ed989cc790650e10f1c4db1524d64c;hb=fc754c60dc1e8bfb7c6721150f8e7d4ac1a41c11;hp=0000000000000000000000000000000000000000;hpb=aa0b8f9d93419c829a260f2d18fce92b90ab532c;p=yangtools.git diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1312Test.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1312Test.java new file mode 100644 index 0000000000..8723e272a3 --- /dev/null +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1312Test.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.yang.stmt; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import java.net.URI; +import java.util.Optional; +import org.junit.Test; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement; + +public class YT1312Test { + @Test + public void testRefineDefault() throws Exception { + final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1312/foo.yang") + .getModuleStatements().get(QNameModule.create(URI.create("foo"))); + + final LeafListEffectiveStatement grpFoo = module + .findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow() + .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow(); + final LeafListEffectiveStatement foo = module + .findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow(); + + assertNotSame(foo, grpFoo); + assertEquals(Optional.empty(), grpFoo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class)); + assertEquals(Optional.of("abc"), foo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class)); + } +}