Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / yin / YinFileImportStmtTest.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.yin;
9
10 import static org.hamcrest.CoreMatchers.anyOf;
11 import static org.hamcrest.core.Is.is;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertThat;
15
16 import java.io.IOException;
17 import java.net.URISyntaxException;
18 import java.text.ParseException;
19 import java.util.Iterator;
20 import java.util.Set;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.opendaylight.yangtools.yang.model.api.Module;
24 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
25 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
27 import org.opendaylight.yangtools.yang.stmt.TestUtils;
28 import org.xml.sax.SAXException;
29
30 public class YinFileImportStmtTest {
31
32     private SchemaContext context;
33
34     @Before
35     public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
36         context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
37         assertEquals(9, context.getModules().size());
38
39     }
40
41     @Test
42     public void testImport() throws ParseException {
43         Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
44         assertNotNull(testModule);
45
46         Set<ModuleImport> imports = testModule.getImports();
47         assertEquals(2, imports.size());
48
49         Iterator<ModuleImport> importsIterator = imports.iterator();
50         ModuleImport moduleImport = importsIterator.next();
51
52         assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
53         assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
54
55         moduleImport = importsIterator.next();
56         assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
57         assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
58     }
59 }