public static <K, N, V, S extends State>
            InternalKvState<K, N, ?> createStateAndWrapWithLatencyTrackingIfEnabled(
                    InternalKvState<K, N, ?> kvState,
                    StateDescriptor<S, V> stateDescriptor,
                    LatencyTrackingStateConfig latencyTrackingStateConfig)
                    throws Exception {
        if (latencyTrackingStateConfig.isEnabled()) {
            return new LatencyTrackingStateFactory<>(
                            kvState, stateDescriptor, latencyTrackingStateConfig)
                    .createState();
        }
        return kvState;
    }
@TestTemplate
    @SuppressWarnings("unchecked")
    <K, N> void testTrackValueState() throws Exception {
        InternalValueState<K, N, String> valueState = mock(InternalValueState.class);
        ValueStateDescriptor<String> valueStateDescriptor =
                new ValueStateDescriptor<>("value", String.class);
        InternalKvState<K, ?, ?> latencyTrackingState =
                LatencyTrackingStateFactory.createStateAndWrapWithLatencyTrackingIfEnabled(
                        valueState, valueStateDescriptor, getLatencyTrackingStateConfig());
        if (enableLatencyTracking) {
            assertThat(latencyTrackingState).isInstanceOf(LatencyTrackingValueState.class);
        } else {
            assertThat(latencyTrackingState).isEqualTo(valueState);
        }
    }