Remove unused TestUtils methods 15/97715/5
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 2 Oct 2021 18:37:26 +0000 (20:37 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Oct 2021 08:36:40 +0000 (10:36 +0200)
We have some code duplication and unused code paths, clean that up.

Change-Id: If3b675420179b285417114a59e386fb57684926c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java

index 65378f78da4d14735c8e56ccd2ac6b7b7d752ba5..4015e109116bea7f9fa31ceb7433370514c78d57 100644 (file)
@@ -18,7 +18,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -37,13 +36,9 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinTextToDomTransform
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
 public final class TestUtils {
-    private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
-
     private TestUtils() {
         // Hidden on purpose
     }
@@ -70,23 +65,9 @@ public final class TestUtils {
 
     public static EffectiveModelContext loadModules(final Class<?> cls, final String resourceDirectory)
             throws Exception {
-        return loadModules(cls.getResource(resourceDirectory).toURI());
-    }
-
-    public static EffectiveModelContext loadModules(final URI resourceDirectory)
-            throws ReactorException, IOException, YangSyntaxErrorException {
-        final BuildAction reactor = RFC7950Reactors.defaultReactor().newBuild();
-        File[] files = new File(resourceDirectory).listFiles();
-
-        for (File file : files) {
-            if (file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION)) {
-                reactor.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forPath(file.toPath())));
-            } else {
-                LOG.info("Ignoring non-yang file {}", file);
-            }
-        }
-
-        return reactor.buildEffective();
+        return RFC7950Reactors.defaultReactor().newBuild()
+            .addSources(loadSources(cls, resourceDirectory))
+            .buildEffective();
     }
 
     public static EffectiveModelContext loadModuleResources(final Class<?> refClass, final String... resourceNames)
@@ -180,11 +161,6 @@ public final class TestUtils {
         return parseYangSources(sources);
     }
 
-    public static EffectiveModelContext parseYangSources(final Collection<File> files)
-            throws ReactorException, IOException, YangSyntaxErrorException {
-        return parseYangSources(files.toArray(new File[files.size()]));
-    }
-
     public static EffectiveModelContext parseYangSource(final String yangSourceFilePath)
             throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {