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.MatcherAssert.assertThat;
12 import static org.hamcrest.core.Is.is;
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
16 import java.util.Collection;
17 import java.util.Iterator;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
23 public class YinFileImportStmtTest extends AbstractYinModulesTest {
26 public void testImport() {
27 Module testModule = context.findModules("ietf-netconf-monitoring").iterator().next();
28 assertNotNull(testModule);
30 Collection<? extends ModuleImport> imports = testModule.getImports();
31 assertEquals(2, imports.size());
33 Iterator<? extends ModuleImport> importsIterator = imports.iterator();
34 ModuleImport moduleImport = importsIterator.next();
36 final var nameMatch = anyOf(is(Unqualified.of("ietf-yang-types")),
37 is(Unqualified.of("ietf-inet-types")));
39 assertThat(moduleImport.getModuleName(), nameMatch);
40 assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));
42 moduleImport = importsIterator.next();
43 assertThat(moduleImport.getModuleName(), nameMatch);
44 assertThat(moduleImport.getPrefix(), anyOf(is("yang"), is("inet")));