2 * Copyright (c) 2016 Cisco Systems, Inc. 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.openconfigver;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
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;
21 public class OpenconfigVersionPositionTest {
24 public void positionHeadTest() throws Exception {
25 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-head",
26 StatementParserMode.SEMVER_MODE);
27 assertNotNull(context);
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();
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());
39 public void positionMiddleTest() throws Exception {
40 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-middle",
41 StatementParserMode.SEMVER_MODE);
42 assertNotNull(context);
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();
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());
54 public void positiontailTest() throws Exception {
55 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-tail",
56 StatementParserMode.SEMVER_MODE);
57 assertNotNull(context);
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();
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());