Remove YangModelDependencyInfo.forResource() 11/99011/7
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 15 Dec 2021 11:17:50 +0000 (12:17 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 15 Dec 2021 14:45:15 +0000 (15:45 +0100)
This method has been deprecated and users have been migrated. Remove it.

Change-Id: I7583fc89c85aa4af12c18b3cc9504e5aecf833d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolverTest.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java

index 88a1189597c536dec80d6d260ee28ba485df5b5a..47028cd9066f7abc591ac021ef6336b823072f46 100644 (file)
@@ -15,21 +15,18 @@ import java.util.Map;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo;
+import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo.ModuleDependencyInfo;
 
 @Deprecated
 public class DependencyResolverTest {
-
     @Test
     public void testModulesWithoutRevisionAndImport() throws Exception {
         final Map<SourceIdentifier, YangModelDependencyInfo> map = new HashMap<>();
-
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(),
-            "/no-revision/imported.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(),
-            "/no-revision/imported@2012-12-12.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(),
-            "/no-revision/top@2012-10-10.yang"));
+        addToMap(map, "/no-revision/imported.yang");
+        addToMap(map, "/no-revision/imported@2012-12-12.yang");
+        addToMap(map, "/no-revision/top@2012-10-10.yang");
 
         final DependencyResolver resolved = RevisionDependencyResolver.create(map);
 
@@ -40,11 +37,10 @@ public class DependencyResolverTest {
     @Test
     public void testSubmoduleNoModule() throws Exception {
         final Map<SourceIdentifier, YangModelDependencyInfo> map = new HashMap<>();
-
         // Subfoo does not have parent in reactor
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/subfoo.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/bar.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/baz.yang"));
+        addToMap(map, "/model/subfoo.yang");
+        addToMap(map, "/model/bar.yang");
+        addToMap(map, "/model/baz.yang");
 
         final DependencyResolver resolved = RevisionDependencyResolver.create(map);
 
@@ -56,11 +52,10 @@ public class DependencyResolverTest {
     @Test
     public void testSubmodule() throws Exception {
         final Map<SourceIdentifier, YangModelDependencyInfo> map = new HashMap<>();
-
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/subfoo.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/foo.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/bar.yang"));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/baz.yang"));
+        addToMap(map, "/model/subfoo.yang");
+        addToMap(map, "/model/foo.yang");
+        addToMap(map, "/model/bar.yang");
+        addToMap(map, "/model/baz.yang");
 
         final DependencyResolver resolved = RevisionDependencyResolver.create(map);
         assertEquals(0, resolved.getUnresolvedSources().size());
@@ -69,12 +64,9 @@ public class DependencyResolverTest {
     }
 
     private static void addToMap(final Map<SourceIdentifier, YangModelDependencyInfo> map,
-            final YangModelDependencyInfo yangModelDependencyInfo) {
-        map.put(getSourceId(yangModelDependencyInfo), yangModelDependencyInfo);
-    }
-
-    private static SourceIdentifier getSourceId(final YangModelDependencyInfo depInfo) {
-        final String name = depInfo.getName();
-        return RevisionSourceIdentifier.create(name, depInfo.getRevision());
+            final String yangFileName) throws Exception {
+        final var info = ModuleDependencyInfo.forYangText(YangTextSchemaSource.forResource(DependencyResolverTest.class,
+            yangFileName));
+        map.put(RevisionSourceIdentifier.create(info.getName(), info.getRevision()), info);
     }
 }
index 40b1116fd82e039b8eaa1f09a0dffd39b7325229..e642bb2b4d7883503fa45c6b7d6d7f3d4b0e5a4a 100644 (file)
@@ -199,28 +199,6 @@ public abstract class YangModelDependencyInfo {
         throw new IllegalArgumentException("Root of parsed AST must be either module or submodule");
     }
 
-    /**
-     * Extracts {@link YangModelDependencyInfo} from input stream containing a YANG model. This parsing does not
-     * validate full YANG module, only parses header up to the revisions and imports.
-     *
-     * @param refClass Base search class
-     * @param resourceName resource name, relative to refClass
-     * @return {@link YangModelDependencyInfo}
-     * @throws YangSyntaxErrorException If the resource does not pass syntactic analysis
-     * @throws IOException When the resource cannot be read
-     * @throws IllegalArgumentException
-     *             If input stream is not valid YANG stream
-     * @deprecated This method was used by testing framework and was deemed to be potentially useful to the outside
-     *             world. With Java Platform Module System, though, the resource loading rules have changed to the point
-     *             where we no longer can guarantee it working correctly, as the results depend on the resource path.
-     *             Users are advised to use {@link #forYangText(YangTextSchemaSource)}.
-     */
-    @Deprecated(forRemoval = true)
-    public static YangModelDependencyInfo forResource(final Class<?> refClass, final String resourceName)
-            throws IOException, YangSyntaxErrorException {
-        return forYangText(YangTextSchemaSource.forResource(refClass, resourceName));
-    }
-
     /**
      * Extracts {@link YangModelDependencyInfo} from a {@link YangTextSchemaSource}. This parsing does not
      * validate full YANG module, only parses header up to the revisions and imports.