public static OffsetAndMetadata fromRequest(
        OffsetCommitRequestData.OffsetCommitRequestPartition partition,
        long currentTimeMs,
        OptionalLong expireTimestampMs
    ) {
        return new OffsetAndMetadata(
            partition.committedOffset(),
            ofSentinel(partition.committedLeaderEpoch()),
            partition.committedMetadata() == null ?
                OffsetAndMetadata.NO_METADATA : partition.committedMetadata(),
            partition.commitTimestamp() == OffsetCommitRequest.DEFAULT_TIMESTAMP ?
                currentTimeMs : partition.commitTimestamp(),
            expireTimestampMs
        );
    }
@Test
    public void testFromRequest() {
        MockTime time = new MockTime();

        OffsetCommitRequestData.OffsetCommitRequestPartition partition =
            new OffsetCommitRequestData.OffsetCommitRequestPartition()
                .setPartitionIndex(0)
                .setCommittedOffset(100L)
                .setCommittedLeaderEpoch(-1)
                .setCommittedMetadata(null)
                .setCommitTimestamp(-1L);

        assertEquals(
            new OffsetAndMetadata(
                100L,
                OptionalInt.empty(),
                "",
                time.milliseconds(),
                OptionalLong.empty()
            ), OffsetAndMetadata.fromRequest(
                partition,
                time.milliseconds(),
                OptionalLong.empty()
            )
        );

        partition
            .setCommittedLeaderEpoch(10)
            .setCommittedMetadata("hello")
            .setCommitTimestamp(1234L);

        assertEquals(
            new OffsetAndMetadata(
                100L,
                OptionalInt.of(10),
                "hello",
                1234L,
                OptionalLong.empty()
            ), OffsetAndMetadata.fromRequest(
                partition,
                time.milliseconds(),
                OptionalLong.empty()
            )
        );

        assertEquals(
            new OffsetAndMetadata(
                100L,
                OptionalInt.of(10),
                "hello",
                1234L,
                OptionalLong.of(5678L)
            ), OffsetAndMetadata.fromRequest(
                partition,
                time.milliseconds(),
                OptionalLong.of(5678L)
            )
        );
    }