syhily commented on a change in pull request #17159:
URL: https://github.com/apache/flink/pull/17159#discussion_r703484098



##########
File path: 
flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/enumerator/topic/TopicRangeTest.java
##########
@@ -33,26 +30,22 @@
 /** Unit tests for {@link TopicRange}. */
 class TopicRangeTest {
 
-    private final Random random = new Random(System.currentTimeMillis());
-
-    @RepeatedTest(10)
-    @SuppressWarnings("java:S5778")
+    @Test
     void rangeCreationHaveALimitedScope() {
-        assertThrows(
-                IllegalArgumentException.class,
-                () -> new TopicRange(-1, random.nextInt(MAX_RANGE)));
-        assertThrows(
-                IllegalArgumentException.class,
-                () -> new TopicRange(1, MAX_RANGE + random.nextInt(10000)));
-
-        assertDoesNotThrow(() -> new TopicRange(1, random.nextInt(MAX_RANGE)));
+        // Negative start.
+        assertThrows(IllegalArgumentException.class, () -> new TopicRange(-1, 
1));
+        // End below the boundary.
+        assertDoesNotThrow(() -> new TopicRange(1, MAX_RANGE - 1));
+        // End on the boundary.
+        assertDoesNotThrow(() -> new TopicRange(1, MAX_RANGE));
+        // End above the boundary.
+        assertThrows(IllegalArgumentException.class, () -> new TopicRange(1, 
MAX_RANGE + 1));
     }
 
     @Test
     void topicRangeIsSerializable() throws Exception {
-        TopicRange range = new TopicRange(10, random.nextInt(MAX_RANGE));
-        TopicRange cloneRange = InstantiationUtil.clone(range);
-
+        final TopicRange range = new TopicRange(10, 9);

Review comment:
       This test data is invalid. I think we may better make sure the `start < 
end`.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to