private void mockPrepareLeaving(ShareMembershipManager membershipManager) {
        String topicName = "topic1";
        TopicPartition ownedPartition = new TopicPartition(topicName, 0);

        // Start leaving group, blocked waiting for callback to complete.
        when(subscriptionState.assignedPartitions()).thenReturn(Collections.singleton(ownedPartition));
        when(subscriptionState.hasAutoAssignedPartitions()).thenReturn(true);
        doNothing().when(subscriptionState).markPendingRevocation(anySet());
        membershipManager.leaveGroup();
    }
Member that intentionally leaves the group (via unsubscribe) should release assignment,
reset epoch to -1, keep member ID, and transition to {@link MemberState#LEAVING} to send out a
heartbeat with the leave epoch. Once the heartbeat request is sent out, the member should
transition to {@link MemberState#UNSUBSCRIBED}
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ShareMembershipManagerTest.java