Bug 4640: Change semantic-version to openconfig-version
[yangtools.git] / yang / yang-parser-impl / 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 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 OpenconfigVersionIgnoringRevisionTest {
22
23     @Test
24     public void ignoringRevisionTest() throws Exception {
25         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision",
26                 StatementParserMode.OPENCONFIG_VER_MODE);
27         assertNotNull(context);
28
29         Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
30         Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
31         Module semVer = context.findModuleByNamespace(new URI("http://openconfig.net/yang/openconfig-ext"))
32                 .iterator().next();
33
34         assertEquals(SemVer.valueOf("0.0.1"), semVer.getOpenconfigVersion());
35         assertEquals(SemVer.valueOf("0.1.1"), foo.getOpenconfigVersion());
36         assertEquals(SemVer.valueOf("0.1.2"), bar.getOpenconfigVersion());
37     }
38
39     @Test
40     public void ignoringRevision2Test() throws Exception {
41         SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/ignoring-revision-2",
42                 StatementParserMode.OPENCONFIG_VER_MODE);
43         assertNotNull(context);
44
45         Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
46         Module semVer = context.findModuleByNamespace(new URI("http://openconfig.net/yang/openconfig-ext"))
47                 .iterator().next();
48         Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
49
50         assertEquals(SemVer.valueOf("0.0.1"), semVer.getOpenconfigVersion());
51         assertEquals(SemVer.valueOf("0.1.1"), foo.getOpenconfigVersion());
52         assertEquals(SemVer.valueOf("0.1.2"), bar.getOpenconfigVersion());
53     }
54 }