Populate parser/ hierarchy
[yangtools.git] / parser / 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.MatcherAssert.assertThat;
12 import static org.hamcrest.core.Is.is;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15
16 import java.text.ParseException;
17 import java.util.Collection;
18 import java.util.Iterator;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
22 import org.opendaylight.yangtools.yang.stmt.TestUtils;
23
24 public class YinFileImportStmtTest extends AbstractYinModulesTest {
25
26     @Test
27     public void testImport() throws ParseException {
28         Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
29         assertNotNull(testModule);
30
31         Collection<? extends ModuleImport> imports = testModule.getImports();
32         assertEquals(2, imports.size());
33
34         Iterator<? extends ModuleImport> importsIterator = imports.iterator();
35         ModuleImport moduleImport = importsIterator.next();
36
37         assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
38         assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
39
40         moduleImport = importsIterator.next();
41         assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
42         assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
43     }
44 }