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.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertNotSame;
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;
20 class YT1312Test extends AbstractYangTest {
22 void testRefineDefault() {
23 final var module = assertEffectiveModel("/bugs/YT1312/foo.yang").getModuleStatement(QNameModule.of("foo"));
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();
31 assertNotSame(foo, grpFoo);
32 assertEquals(Optional.empty(), grpFoo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));
33 assertEquals(Optional.of("abc"), foo.findFirstEffectiveSubstatementArgument(DefaultEffectiveStatement.class));