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


##########
clients/src/test/java/org/apache/kafka/common/utils/annotation/ApiKeyVersionsProvider.java:
##########
@@ -23,16 +23,36 @@
 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();
+        fromVersion = source.fromVersion() == -1 ? apiKey.oldestVersion() : 
source.fromVersion();
+        toVersion = source.toVersion() == -1 ? 
apiKey.latestVersion(source.enableUnstableLastVersion()) : source.toVersion();
+
+        if (fromVersion > toVersion) {
+            throw new IllegalArgumentException(String.format("The fromVersion 
%s is larger than the toVersion %s",
+                fromVersion, toVersion));
+        }
+
+        if (fromVersion < apiKey.oldestVersion()) {
+            throw new IllegalArgumentException(String.format("The fromVersion 
%s is older than the oldest version %s",
+                fromVersion, apiKey.oldestVersion()));
+        }
+
+        if (toVersion < 
apiKey.latestVersion(source.enableUnstableLastVersion())) {

Review Comment:
   Sorry, copy-pasting issue. Fixed it and added some tests.



-- 
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