@Test
    public void shouldThrowOnInvalidDateFormatOrNullTimestamp() {
        // check some invalid formats
        // test null timestamp
        assertTrue(assertThrows(IllegalArgumentException.class, () ->
            Utils.getDateTime(null)
        ).getMessage().contains("Error parsing timestamp with null value"));

        // test pattern: yyyy-MM-dd'T'HH:mm:ss.X
        checkExceptionForGetDateTimeMethod(() ->
            invokeGetDateTimeMethod(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.X"))
        );

        // test pattern: yyyy-MM-dd HH:mm:ss
        assertTrue(assertThrows(ParseException.class, () ->
            invokeGetDateTimeMethod(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"))
        ).getMessage().contains("It does not contain a 'T' according to ISO8601 format"));

        // KAFKA-10685: use DateTimeFormatter generate micro/nano second timestamp
        final DateTimeFormatter formatter = new DateTimeFormatterBuilder()
            .appendPattern("yyyy-MM-dd'T'HH:mm:ss")
            .appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
            .toFormatter();
        final LocalDateTime timestampWithNanoSeconds = LocalDateTime.of(2020, 11, 9, 12, 34, 56, 123456789);
        final LocalDateTime timestampWithMicroSeconds = timestampWithNanoSeconds.truncatedTo(ChronoUnit.MICROS);
        final LocalDateTime timestampWithSeconds = timestampWithNanoSeconds.truncatedTo(ChronoUnit.SECONDS);

        // test pattern: yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS
        checkExceptionForGetDateTimeMethod(() ->
            Utils.getDateTime(formatter.format(timestampWithNanoSeconds))
        );

        // test pattern: yyyy-MM-dd'T'HH:mm:ss.SSSSSS
        checkExceptionForGetDateTimeMethod(() ->
            Utils.getDateTime(formatter.format(timestampWithMicroSeconds))
        );

        // test pattern: yyyy-MM-dd'T'HH:mm:ss
        checkExceptionForGetDateTimeMethod(() ->
            Utils.getDateTime(formatter.format(timestampWithSeconds))
        );
    }
Expectation setter for multiple reads where each one reads random bytes to the buffer.

@param channelMock           The mocked FileChannel object
@param bufferSize            The buffer size
@return Expected buffer string
@throws IOException          If an I/O error occurs
clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java