55dc9991853bfcbbb509264306e682068df5279d
[yangtools.git] / yang / yang-parser-impl / 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 java.net.URI;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.concepts.SemVer;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
19 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
20
21 public class OpenconfigVersionPositionTest {
22
23     @Test
24     public void positionHeadTest() throws Exception {
25         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-head",
26                 StatementParserMode.SEMVER_MODE);
27         assertNotNull(context);
28
29         Module foo = context.findModules(new URI("foo")).iterator().next();
30         Module bar = context.findModules(new URI("bar")).iterator().next();
31         Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next();
32
33         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
34         assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
35         assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
36     }
37
38     @Test
39     public void positionMiddleTest() throws Exception {
40         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-middle",
41                 StatementParserMode.SEMVER_MODE);
42         assertNotNull(context);
43
44         Module foo = context.findModules(new URI("foo")).iterator().next();
45         Module bar = context.findModules(new URI("bar")).iterator().next();
46         Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next();
47
48         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
49         assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
50         assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
51     }
52
53     @Test
54     public void positiontailTest() throws Exception {
55         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-tail",
56                 StatementParserMode.SEMVER_MODE);
57         assertNotNull(context);
58
59         Module foo = context.findModules(new URI("foo")).iterator().next();
60         Module bar = context.findModules(new URI("bar")).iterator().next();
61         Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next();
62
63         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
64         assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
65         assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
66     }
67 }