@Test
    public void testTruncateNotCalledIfSizeIsSameAsTargetSize() throws IOException {
        FileChannel channelMock = mock(FileChannel.class);

        when(channelMock.size()).thenReturn(42L);
        when(channelMock.position(42L)).thenReturn(null);

        FileRecords fileRecords = new FileRecords(tempFile(), channelMock, 0, Integer.MAX_VALUE, false);
        fileRecords.truncateTo(42);

        verify(channelMock, atLeastOnce()).size();
        verify(channelMock, times(0)).truncate(anyLong());
    }
Test that truncateTo only calls truncate on the FileChannel if the size of the
FileChannel is bigger than the target size. This is important because some JVMs
change the mtime of the file, even if truncate should do nothing.
clients/src/test/java/org/apache/kafka/common/record/FileRecordsTest.java