Fixed parsing of typedef statement. Refactored YangParserImpl to improve code readabi...
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / test / java / org / opendaylight / controller / yang / parser / impl / TestUtils.java
index d14c54219e0fd5e1c1d9f3cdae3b0512f8dd654c..26c2c61b98a783aae48517b6cb5c259db85c8bb0 100644 (file)
@@ -49,13 +49,9 @@ final class TestUtils {
         return parser.parseYangModels(testFiles);
     }
 
-    public static Set<Module> loadModules(String... pathToYangFile) throws IOException {
-        YangModelParser parser = new YangParserImpl();
-        List<InputStream> input = new ArrayList<InputStream>();
-        for(String path : pathToYangFile) {
-            input.add(TestUtils.class.getResourceAsStream(path));
-        }
-        Set<Module> modules = new HashSet<Module>(
+    public static Set<Module> loadModules(List<InputStream> input) throws IOException {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = new HashSet<Module>(
                 parser.parseYangModelsFromStreams(input));
         for(InputStream stream : input) {
             stream.close();
@@ -63,11 +59,11 @@ final class TestUtils {
         return modules;
     }
 
-    public static Module loadModule(String pathToYangFile) throws IOException {
-        YangModelParser parser = new YangParserImpl();
-        InputStream stream = TestUtils.class.getResourceAsStream(pathToYangFile);
-        List<InputStream> input = Collections.singletonList(stream);
-        Set<Module> modules = new HashSet<Module>(
+    public static Module loadModule(final InputStream stream) throws
+            IOException {
+        final YangModelParser parser = new YangParserImpl();
+        final List<InputStream> input = Collections.singletonList(stream);
+        final Set<Module> modules = new HashSet<Module>(
                 parser.parseYangModelsFromStreams(input));
         stream.close();
         return modules.iterator().next();