Require SchemaSourceRepresentation.getSymbolicName() 58/95858/6
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 20 Apr 2021 21:31:26 +0000 (23:31 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 21 Apr 2021 05:47:54 +0000 (07:47 +0200)
getSymbolicName() has been retrofitted into the API long time ago, but
due to its default nature a number of of implementations failed to
provide an override.

Make sure the method is required to be implemented, so that
implementators are well aware of it.

JIRA: YANGTOOLS-1275
Change-Id: Ib98189c606312db80480302959ef563342f5b3ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-repo-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaSourceRepresentation.java
yang/yang-repo-fs/src/test/java/org/opendaylight/yangtools/yang/model/repo/fs/FilesystemSchemaSourceCacheIntegrationTest.java
yang/yang-repo-fs/src/test/java/org/opendaylight/yangtools/yang/model/repo/fs/FilesystemSchemaSourceCacheTest.java
yang/yang-repo-spi/src/test/java/org/opendaylight/yangtools/yang/model/repo/spi/GuavaSchemaSourceCacheTest.java

index 431aac46f94a073e298ac56054eccc2815e9bcd6..972c26f6cb96a349991bd3d140f3555720a6e942 100644 (file)
@@ -54,7 +54,5 @@ public interface SchemaSourceRepresentation extends Identifiable<SourceIdentifie
      *
      * @return Symbolic name, if available
      */
-    default Optional<String> getSymbolicName() {
-        return Optional.empty();
-    }
+    Optional<String> getSymbolicName();
 }
index 0c88536b509d01929e51b3fd7f8ae4047ee2da4f..f1dbd0dca048b8c5615bce4a5be3befcb5d12ef3 100644 (file)
@@ -124,6 +124,11 @@ public class FilesystemSchemaSourceCacheIntegrationTest {
                 public InputStream openStream() throws IOException {
                     return new ByteArrayInputStream("running".getBytes(StandardCharsets.UTF_8));
                 }
+
+                @Override
+                public Optional<String> getSymbolicName() {
+                    return Optional.empty();
+                }
             }), PotentialSchemaSource.create(runningId, YangTextSchemaSource.class,
                 PotentialSchemaSource.Costs.REMOTE_IO.getValue()));
 
index 54ccc2ad0bb84dcaa8a4047f0c517ddec3671728..91f27b6c8dbbba7a47079dfd51dbed1cda1d0d5b 100644 (file)
@@ -33,6 +33,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
@@ -224,7 +225,6 @@ public class FilesystemSchemaSourceCacheTest {
     }
 
     private class TestingYangSource extends YangTextSchemaSource {
-
         private final String content;
 
         TestingYangSource(final String name, final String revision, final String content) {
@@ -241,5 +241,10 @@ public class FilesystemSchemaSourceCacheTest {
         public InputStream openStream() throws IOException {
             return new ByteArrayInputStream(this.content.getBytes(StandardCharsets.UTF_8));
         }
+
+        @Override
+        public Optional<String> getSymbolicName() {
+            return Optional.empty();
+        }
     }
 }
index f8fe85057361c16d780d7f3eb6a3ae67015040c4..36324e84fe8f0826499b10e1ad39407a1c5ba40e 100644 (file)
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
+import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.junit.Before;
@@ -125,10 +126,9 @@ public class GuavaSchemaSourceCacheTest {
     }
 
     private class TestingYangSource extends YangTextSchemaSource {
-
         private final String content;
 
-        protected TestingYangSource(final String name, final String revision, final String content) {
+        TestingYangSource(final String name, final String revision, final String content) {
             super(RevisionSourceIdentifier.create(name, Revision.ofNullable(revision)));
             this.content = content;
         }
@@ -142,6 +142,10 @@ public class GuavaSchemaSourceCacheTest {
         public InputStream openStream() throws IOException {
             return new ByteArrayInputStream(this.content.getBytes(StandardCharsets.UTF_8));
         }
-    }
 
+        @Override
+        public Optional<String> getSymbolicName() {
+            return Optional.empty();
+        }
+    }
 }