Remove deprecated Yin/YangStatementSourceImpl
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / util / YangModelDependencyInfoTest.java
1 /*
2  * Copyright (c) 2014 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.parser.impl.util;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertTrue;
16
17 import java.io.IOException;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
20
21 public class YangModelDependencyInfoTest {
22
23     @Test
24     public void testModuleWithNoImports() throws IOException, YangSyntaxErrorException {
25         YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
26             "/ietf/ietf-inet-types@2010-09-24.yang");
27         assertNotNull(info);
28         assertEquals("ietf-inet-types", info.getName());
29         assertEquals("2010-09-24", info.getFormattedRevision());
30         assertNotNull(info.getDependencies());
31
32         assertTrue(info.equals(info));
33     }
34
35     @Test
36     public void testModuleWithImports() throws IOException, YangSyntaxErrorException {
37         YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
38                 "/parse-methods/dependencies/m2@2013-09-30.yang");
39         assertNotNull(info);
40         assertEquals("m2", info.getName());
41         assertEquals("2013-09-30", info.getFormattedRevision());
42         assertNotNull(info.getDependencies());
43         assertEquals(2, info.getDependencies().size());
44     }
45
46     @Test
47     public void testModuleWithoutRevision() throws IOException, YangSyntaxErrorException {
48         YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
49                 "/no-revision/module-without-revision.yang");
50         assertNotNull(info);
51         assertEquals("module-without-revision", info.getName());
52         assertNull(info.getFormattedRevision());
53     }
54
55     @Test
56     public void testEquals() throws IOException, YangSyntaxErrorException {
57         YangModelDependencyInfo info1 = YangModelDependencyInfo.forResource(getClass(),
58             "/ietf/ietf-inet-types@2010-09-24.yang");
59         YangModelDependencyInfo info2 = YangModelDependencyInfo.forResource(getClass(),
60             "/no-revision/module-without-revision.yang");
61
62         assertTrue(info1.equals(info1));
63         assertFalse(info1.equals(null));
64         assertFalse(info1.equals(info2));
65     }
66
67     @Test
68     public void testHashcode() throws IOException, YangSyntaxErrorException {
69         YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
70                 "/no-revision/module-without-revision.yang");
71         assertNotEquals("hashcode", 31, info.hashCode());
72     }
73 }