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


##########
share/src/test/java/org/apache/kafka/server/share/fetch/PartitionMaxBytesStrategyTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server.share.fetch;
+
+import org.apache.kafka.common.TopicIdPartition;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.Uuid;
+import 
org.apache.kafka.server.share.fetch.PartitionMaxBytesStrategy.StrategyType;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class PartitionMaxBytesStrategyTest {
+
+    @Test
+    public void testConstructor() {
+        assertThrows(IllegalArgumentException.class, () -> 
PartitionMaxBytesStrategy.type(null));
+        assertDoesNotThrow(() -> 
PartitionMaxBytesStrategy.type(StrategyType.UNIFORM));
+    }
+
+    @Test
+    public void testCheckValidArguments() {
+        TopicIdPartition topicIdPartition1 = new 
TopicIdPartition(Uuid.randomUuid(), new TopicPartition("topic1", 0));
+        TopicIdPartition topicIdPartition2 = new 
TopicIdPartition(Uuid.randomUuid(), new TopicPartition("topic1", 1));
+        TopicIdPartition topicIdPartition3 = new 
TopicIdPartition(Uuid.randomUuid(), new TopicPartition("topic2", 0));
+        Set<TopicIdPartition> partitions = new LinkedHashSet<>();
+        partitions.add(topicIdPartition1);
+        partitions.add(topicIdPartition2);
+        partitions.add(topicIdPartition3);
+
+        // acquired partitions size is 0.
+        assertThrows(IllegalArgumentException.class, () -> 
PartitionMaxBytesStrategy.checkValidArguments(
+            100, partitions, 0));
+        // empty partitions set.
+        assertThrows(IllegalArgumentException.class, () -> 
PartitionMaxBytesStrategy.checkValidArguments(
+            100, Collections.EMPTY_SET, 20));

Review Comment:
   I apologize for the delayed review. Could you please use `Set.of()` to 
address the following warnings?
   
   ```
   > Task :share:compileTestJava
   Note: 
/home/jenkins/kafka/share/src/test/java/org/apache/kafka/server/share/fetch/PartitionMaxBytesStrategyTest.java
 uses unchecked or unsafe operations.
   Note: Recompile with -Xlint:unchecked for details.
   
   ```



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