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.model.util;
10 import static org.hamcrest.CoreMatchers.instanceOf;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertFalse;
15 import org.junit.BeforeClass;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.PathEffectiveStatement;
22 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
23 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
25 public class YT1282Test {
26 private static EffectiveModelContext context;
28 private final SchemaInferenceStack stack = SchemaInferenceStack.of(context);
31 public static void beforeClass() {
32 context = YangParserTestUtils.parseYangResource("/yt1282.yang");
36 public void testResolveTypedef() {
37 final TypeEffectiveStatement<?> type = stack.enterTypedef(QName.create("foo", "foo"))
38 .findFirstEffectiveSubstatement(TypeEffectiveStatement.class).orElseThrow();
39 assertFalse(stack.inInstantiatedContext());
40 assertFalse(stack.inGrouping());
42 final EffectiveStatement<?, ?> bar = stack.resolvePathExpression(
43 type.findFirstEffectiveSubstatementArgument(PathEffectiveStatement.class).orElseThrow());
44 assertThat(bar, instanceOf(LeafEffectiveStatement.class));
45 assertEquals(QName.create("foo", "bar"), bar.argument());