Bug 5085: Clean-up test and retest JUnit tests
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / MappedEffectiveBuildTest.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
9 package org.opendaylight.yangtools.yang.stmt;
10
11 import static org.junit.Assert.assertEquals;
12 import java.io.FileNotFoundException;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
14 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
15 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
16 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
17 import java.util.Map.Entry;
18 import java.util.Set;
19 import java.util.Map;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import java.util.List;
22 import java.util.Arrays;
23 import java.net.URISyntaxException;
24 import java.io.File;
25 import org.junit.Test;
26
27 public class MappedEffectiveBuildTest {
28
29     @Test
30     public void mappedBuildTest() throws URISyntaxException, SourceException,
31             FileNotFoundException, ReactorException {
32         File sourceDir = new File(getClass().getResource("/mapped-build/")
33                 .toURI());
34         List<File> yangFiles = Arrays.asList(sourceDir.listFiles());
35
36         assertEquals(4, yangFiles.size());
37
38         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
39         Map<File, Module> parseYangModelsMapped = reactor
40                 .buildEffectiveMappedToSource(yangFiles);
41
42         assertEquals(2, parseYangModelsMapped.size());
43
44         Set<Entry<File, Module>> mapEntrySet = parseYangModelsMapped.entrySet();
45         for (Entry<File, Module> entry : mapEntrySet) {
46             assertEquals(entry.getKey().getPath(), entry.getValue()
47                     .getModuleSourcePath());
48         }
49     }
50 }