reswqa commented on code in PR #19946:
URL: https://github.com/apache/flink/pull/19946#discussion_r896430817


##########
flink-core/src/test/java/org/apache/flink/api/common/io/BinaryInputFormatTest.java:
##########
@@ -154,17 +170,60 @@ public void testGetStatisticsMultiplePaths() throws 
IOException {
         inputFormat.setBlockSize(blockSize);
 
         BaseStatistics stats = inputFormat.getStatistics(null);
-        Assert.assertEquals(
-                "The file size statistics is wrong",
-                blockSize * (numBlocks1 + numBlocks2),
-                stats.getTotalInputSize());
+
+        assertThat(stats.getTotalInputSize())
+                .as("The file size statistics is wrong")
+                .isEqualTo(blockSize * (numBlocks1 + numBlocks2));
+    }
+
+    @Test
+    public void testCreateInputSplitsWithEmptySplit() throws IOException {
+        final int blockInfoSize = new BlockInfo().getInfoSize();
+        final int blockSize = blockInfoSize + 8;
+        final int numBlocks = 3;
+        final int minNumSplits = 5;
+
+        // create temporary file with 3 blocks
+        final File tempFile =
+                createBinaryInputFile(
+                        "test_create_input_splits_with_empty_split", 
blockSize, numBlocks);
+
+        final Configuration config = new Configuration();
+        config.setLong("input.block_size", blockSize + 10);
+
+        final BinaryInputFormat<Record> inputFormat = new 
MyBinaryInputFormat();
+        inputFormat.setFilePath(tempFile.toURI().toString());
+        inputFormat.setBlockSize(blockSize);
+
+        inputFormat.configure(config);
+
+        FileInputSplit[] inputSplits = 
inputFormat.createInputSplits(minNumSplits);
+
+        assertThat(inputSplits.length)
+                .as("Returns requested numbers of splits.")
+                .isEqualTo(minNumSplits);
+
+        assertThat(inputSplits[0].getLength())
+                .as("1. split has block size length.")

Review Comment:
   IMO, `as` is used to add description when this assert is not pass.
   The error message will be displayed in the following format:
   org.opentest4j.AssertionFailedError: [description in as()] 
   So I think the `as` description in these tests should be more accurate, such 
as
   "1. split should/must has block size length."



-- 
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-unsubscr...@flink.apache.org

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

Reply via email to