public void transitionTo(ClassicGroupState groupState) {
        assertValidTransition(groupState);
        previousState = state;
        state = groupState;
        currentStateTimestamp = Optional.of(time.milliseconds());
        metrics.onClassicGroupStateTransition(previousState, state);
    }
@Test
    public void testStateTransitionMetrics() {
        // Confirm metrics is not updated when a new GenericGroup is created but only when the group transitions
        // its state.
        GroupCoordinatorMetricsShard metrics = mock(GroupCoordinatorMetricsShard.class);
        ClassicGroup group = new ClassicGroup(new LogContext(), "groupId", EMPTY, Time.SYSTEM, metrics);
        verify(metrics, times(0)).onClassicGroupStateTransition(any(), any());

        group.transitionTo(PREPARING_REBALANCE);
        verify(metrics, times(1)).onClassicGroupStateTransition(EMPTY, PREPARING_REBALANCE);

        group.transitionTo(COMPLETING_REBALANCE);
        verify(metrics, times(1)).onClassicGroupStateTransition(PREPARING_REBALANCE, COMPLETING_REBALANCE);

        group.transitionTo(STABLE);
        verify(metrics, times(1)).onClassicGroupStateTransition(COMPLETING_REBALANCE, STABLE);

        group.transitionTo(DEAD);
        verify(metrics, times(1)).onClassicGroupStateTransition(STABLE, DEAD);
    }