Remove ImportResolutionMode.SEMVER_LATEST
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / openconfigver / OpenconfigVersionPositionTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.stmt.openconfigver;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.concepts.SemVer;
15 import org.opendaylight.yangtools.yang.common.XMLNamespace;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.api.ImportResolutionMode;
19 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
20 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
21
22 @Deprecated(since = "8.0.4", forRemoval = true)
23 public class OpenconfigVersionPositionTest {
24     private static final YangParserConfiguration SEMVER = YangParserConfiguration.builder()
25         .importResolutionMode(ImportResolutionMode.OPENCONFIG_SEMVER)
26         .build();
27
28     @Test
29     public void positionHeadTest() throws Exception {
30         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-head", SEMVER);
31         assertNotNull(context);
32
33         Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
34         Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
35         Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
36             .iterator().next();
37
38         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
39         assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
40         assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
41     }
42
43     @Test
44     public void positionMiddleTest() throws Exception {
45         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-middle", SEMVER);
46         assertNotNull(context);
47
48         Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
49         Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
50         Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
51             .iterator().next();
52
53         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
54         assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
55         assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
56     }
57
58     @Test
59     public void positiontailTest() throws Exception {
60         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-tail", SEMVER);
61         assertNotNull(context);
62
63         Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
64         Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
65         Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
66             .iterator().next();
67
68         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
69         assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
70         assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
71     }
72 }