@Test
    public void testFormatConversionWithNoMessages() {
        TopicPartition tp = new TopicPartition("topic-1", 0);
        LazyDownConversionRecords lazyRecords = new LazyDownConversionRecords(tp, MemoryRecords.EMPTY, RecordBatch.MAGIC_VALUE_V0,
            0, Time.SYSTEM);
        assertEquals(0, lazyRecords.sizeInBytes());
        Iterator<ConvertedRecords<?>> it = lazyRecords.iterator(16 * 1024L);
        assertFalse(it.hasNext(), "No messages should be returned");
    }
Test the new FileRecords with pre allocate as true and file has been clearly shut down, the file will be truncate to end of valid data.
clients/src/test/java/org/apache/kafka/common/record/FileRecordsTest.java