Bug 3670 (part 3/5): Use of new statement parser in yang-maven-plugin
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / effective / build / test / MappedEffectiveBuildTest.java
1 package org.opendaylight.yangtools.yang.stmt.effective.build.test;
2
3 import static org.junit.Assert.assertEquals;
4 import java.io.FileNotFoundException;
5 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
6 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
7 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
8 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
9 import java.util.Map.Entry;
10 import java.util.Set;
11 import java.util.Map;
12 import org.opendaylight.yangtools.yang.model.api.Module;
13 import java.util.List;
14 import java.util.Arrays;
15 import java.net.URISyntaxException;
16 import java.io.File;
17 import org.junit.Test;
18
19 public class MappedEffectiveBuildTest {
20
21     @Test
22     public void mappedBuildTest() throws URISyntaxException, SourceException,
23             FileNotFoundException, ReactorException {
24         File sourceDir = new File(getClass().getResource("/mapped-build/")
25                 .toURI());
26         List<File> yangFiles = Arrays.asList(sourceDir.listFiles());
27
28         assertEquals(4, yangFiles.size());
29
30         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
31         Map<File, Module> parseYangModelsMapped = reactor
32                 .buildEffectiveMappedToSource(yangFiles);
33
34         assertEquals(2, parseYangModelsMapped.size());
35
36         Set<Entry<File, Module>> mapEntrySet = parseYangModelsMapped.entrySet();
37         for (Entry<File, Module> entry : mapEntrySet) {
38             assertEquals(entry.getKey().getPath(), entry.getValue()
39                     .getModuleSourcePath());
40         }
41     }
42 }