2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.stmt.yin;
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;
16 import java.net.URISyntaxException;
17 import java.text.ParseException;
18 import java.util.Iterator;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
25 import org.opendaylight.yangtools.yang.stmt.TestUtils;
27 public class YinFileImportStmtTest {
29 private Set<Module> modules;
32 public void init() throws URISyntaxException, ReactorException {
33 modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
34 assertEquals(9, modules.size());
39 public void testImport() throws ParseException {
40 Module testModule = TestUtils.findModule(modules, "ietf-netconf-monitoring");
41 assertNotNull(testModule);
43 Set<ModuleImport> imports = testModule.getImports();
44 assertEquals(2, imports.size());
46 Iterator<ModuleImport> importsIterator = imports.iterator();
47 ModuleImport moduleImport = importsIterator.next();
49 assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
50 assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
52 moduleImport = importsIterator.next();
53 assertThat(moduleImport.getModuleName(), anyOf(is("ietf-yang-types"), is("ietf-inet-types")));
54 assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));