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;
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;
22 public class OpenconfigVersionPositionTest {
23 private static final YangParserConfiguration SEMVER = YangParserConfiguration.builder()
24 .importResolutionMode(ImportResolutionMode.OPENCONFIG_SEMVER)
28 public void positionHeadTest() throws Exception {
29 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-head", SEMVER);
30 assertNotNull(context);
32 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
33 Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
34 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
37 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
38 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
39 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
43 public void positionMiddleTest() throws Exception {
44 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-middle", SEMVER);
45 assertNotNull(context);
47 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
48 Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
49 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
52 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
53 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
54 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());
58 public void positiontailTest() throws Exception {
59 SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/position/position-tail", SEMVER);
60 assertNotNull(context);
62 Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
63 Module bar = context.findModules(XMLNamespace.of("bar")).iterator().next();
64 Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
67 assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
68 assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
69 assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion().get());