Remove getSemanticVersion()
[yangtools.git] / model / yang-model-util / src / test / java / org / opendaylight / yangtools / yang / model / util / YT1282Test.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.model.util;
9
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;
14
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;
24
25 public class YT1282Test {
26     private static EffectiveModelContext context;
27
28     private final SchemaInferenceStack stack = SchemaInferenceStack.of(context);
29
30     @BeforeClass
31     public static void beforeClass() {
32         context = YangParserTestUtils.parseYangResource("/yt1282.yang");
33     }
34
35     @Test
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());
41
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());
46     }
47 }