Fix if-feature propagation for implicit case statements
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / openconfigver / OpenconfigVersionIgnoringRevisionTest.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 public class OpenconfigVersionIgnoringRevisionTest {
23     private static final YangParserConfiguration SEMVER = YangParserConfiguration.builder()
24         .importResolutionMode(ImportResolutionMode.OPENCONFIG_SEMVER)
25         .build();
26
27     @Test
28     public void ignoringRevisionTest() throws Exception {
29         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision", SEMVER);
30         assertNotNull(context);
31
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"))
35             .iterator().next();
36
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());
40     }
41
42     @Test
43     public void ignoringRevision2Test() throws Exception {
44         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision-2", SEMVER);
45         assertNotNull(context);
46
47         Module foo = context.findModules(XMLNamespace.of("foo")).iterator().next();
48         Module semVer = context.findModules(XMLNamespace.of("http://openconfig.net/yang/openconfig-ext"))
49             .iterator().next();
50         Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
51
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());
55     }
56 }