chia7712 commented on code in PR #19516:
URL: https://github.com/apache/kafka/pull/19516#discussion_r2051729958


##########
clients/src/test/java/org/apache/kafka/common/utils/annotation/ApiKeyVersionsProvider.java:
##########
@@ -23,16 +23,40 @@
 import org.junit.jupiter.params.provider.ArgumentsProvider;
 import org.junit.jupiter.params.support.AnnotationConsumer;
 
+import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 public class ApiKeyVersionsProvider implements ArgumentsProvider, 
AnnotationConsumer<ApiKeyVersionsSource> {
     private ApiKeys apiKey;
+    private short fromVersion;
+    private short toVersion;
 
     public void accept(ApiKeyVersionsSource source) {
         apiKey = source.apiKey();
+
+        short oldestVersion = apiKey.oldestVersion();
+        short latestVersion = 
apiKey.latestVersion(source.enableUnstableLastVersion());
+
+        fromVersion = source.fromVersion() == -1 ? oldestVersion : 
source.fromVersion();
+        toVersion = source.toVersion() == -1 ? latestVersion : 
source.toVersion();
+
+        if (fromVersion > toVersion) {
+            throw new IllegalArgumentException(String.format("The fromVersion 
%s is larger than the toVersion %s",
+                fromVersion, toVersion));
+        }
+
+        if (fromVersion < oldestVersion) {
+            throw new IllegalArgumentException(String.format("The fromVersion 
%s is older than the oldest version %s",
+                fromVersion, oldestVersion));
+        }
+
+        if (toVersion > latestVersion) {
+            throw new IllegalArgumentException(String.format("The toVersion %s 
is newer than the latest version %s",
+                fromVersion, latestVersion));

Review Comment:
   nit: `fromVersion` -> `toVersion`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to