2 * Copyright (c) 2021 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.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotSame;
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;
22 public class YT1312Test extends AbstractYangTest {
24 public void testRefineDefault() {
25 final ModuleEffectiveStatement module = assertEffectiveModel("/bugs/YT1312/foo.yang")
26 .getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
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();
34 assertNotSame(foo, grpFoo);
35 assertEquals(Optional.empty(), grpFoo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
36 assertEquals(Optional.of("abc"), foo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));