Move printing utilities out of StmtTestUtils 18/97718/4
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 2 Oct 2021 20:09:06 +0000 (22:09 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Oct 2021 08:36:41 +0000 (10:36 +0200)
These are used by a single test, move them there.

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

index 120000a3bafe6286a2b82b7f608f553d67ef957a..885fecd4ce5400b1a3de1e49e6c1b8194c0686b1 100644 (file)
@@ -18,16 +18,20 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleLike;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class EffectiveModulesAndSubmodulesTest {
-
+    private static final Logger LOG = LoggerFactory.getLogger(EffectiveModulesAndSubmodulesTest.class);
     private static final StatementStreamSource ROOT_MODULE = sourceForResource(
             "/stmt-test/submodules/root-module.yang");
     private static final StatementStreamSource IMPORTED_MODULE = sourceForResource(
@@ -65,8 +69,8 @@ public class EffectiveModulesAndSubmodulesTest {
                     break;
                 default:
             }
-            StmtTestUtils.printReferences(module, false, "");
-            StmtTestUtils.printChilds(module.getChildNodes(), "      ");
+            printReferences(module, false, "");
+            printChilds(module.getChildNodes(), "      ");
         }
 
         assertNotNull(root);
@@ -197,4 +201,21 @@ public class EffectiveModulesAndSubmodulesTest {
 
         assertFalse(root.equals(imported));
     }
+
+    private static void printReferences(final ModuleLike module, final boolean isSubmodule, final String indent) {
+        LOG.debug("{}{} {}", indent, isSubmodule ? "Submodule" : "Module", module.getName());
+        for (final Submodule submodule : module.getSubmodules()) {
+            printReferences(submodule, true, indent + "      ");
+            printChilds(submodule.getChildNodes(), indent + "            ");
+        }
+    }
+
+    private static void printChilds(final Collection<? extends DataSchemaNode> childNodes, final String indent) {
+        for (final DataSchemaNode child : childNodes) {
+            LOG.debug("{}{} {}", indent, "Child", child.getQName().getLocalName());
+            if (child instanceof DataNodeContainer) {
+                printChilds(((DataNodeContainer) child).getChildNodes(), indent + "      ");
+            }
+        }
+    }
 }
index c06db19a823450c8fadff87b8c3629809b477481..4d4d046d5e1c3d8844876e637645c0061c47c1ab 100644 (file)
@@ -21,14 +21,10 @@ import java.util.List;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
-import org.opendaylight.yangtools.yang.model.api.ModuleLike;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.Submodule;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
@@ -88,24 +84,6 @@ public final class StmtTestUtils {
         }
     }
 
-    public static void printReferences(final ModuleLike module, final boolean isSubmodule, final String indent) {
-        LOG.debug("{}{} {}", indent, isSubmodule ? "Submodule" : "Module", module.getName());
-        for (final Submodule submodule : module.getSubmodules()) {
-            printReferences(submodule, true, indent + "      ");
-            printChilds(submodule.getChildNodes(), indent + "            ");
-        }
-    }
-
-    public static void printChilds(final Collection<? extends DataSchemaNode> childNodes, final String indent) {
-
-        for (final DataSchemaNode child : childNodes) {
-            LOG.debug("{}{} {}", indent, "Child", child.getQName().getLocalName());
-            if (child instanceof DataNodeContainer) {
-                printChilds(((DataNodeContainer) child).getChildNodes(), indent + "      ");
-            }
-        }
-    }
-
     public static EffectiveModelContext parseYangSource(final String yangSourcePath) throws ReactorException,
             URISyntaxException, IOException, YangSyntaxErrorException {
         return parseYangSource(yangSourcePath, YangParserConfiguration.DEFAULT, null);
@@ -119,9 +97,8 @@ public final class StmtTestUtils {
     public static EffectiveModelContext parseYangSource(final String yangSourcePath,
             final YangParserConfiguration config, final Set<QName> supportedFeatures)
                     throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
-        final URL source = StmtTestUtils.class.getResource(yangSourcePath);
-        final File sourceFile = new File(source.toURI());
-        return parseYangSources(config, supportedFeatures, sourceFile);
+        return parseYangSources(config, supportedFeatures,
+            new File(StmtTestUtils.class.getResource(yangSourcePath).toURI()));
     }
 
     public static EffectiveModelContext parseYangSources(final StatementStreamSource... sources)