You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/07 08:32:39 UTC

[GitHub] [flink] PatrickRen commented on a change in pull request #18863: [FLINK-26033][flink-connector-kafka]Fix the problem that robin does not take effect due to upgrading kafka client to 2.4.1 since Flink1.11

PatrickRen commented on a change in pull request #18863:
URL: https://github.com/apache/flink/pull/18863#discussion_r820473799



##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/FlinkRoundRobinPartitionerTest.java
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.flink.streaming.connectors.kafka;
+
+import org.apache.flink.streaming.connectors.kafka.partitioner.FlinkRoundRobinPartitioner;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for the {@link FlinkRoundRobinPartitioner}. */
+public class FlinkRoundRobinPartitionerTest {
+
+    @Test
+    public void testRoundRobin() {
+        FlinkRoundRobinPartitioner<String> part = new FlinkRoundRobinPartitioner<>();
+
+        int[] partitions = new int[] {0, 1, 2, 3, 4};
+        String topic = "topic1";
+        part.open(0, 2);
+
+        assertThat(0).isEqualTo(part.partition("abc1", null, null, topic, partitions));

Review comment:
       nit: The asserting variable should be as the parameter of `assertThat` in order to get a correct error message if assertion fails:
   
   ```java
   assertThat(part.partition("abc1", null, null, topic, partitions)).isEqualTo(0);
   ```




-- 
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: issues-unsubscribe@flink.apache.org

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