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 testTrackListState() throws Exception {
        InternalListState<K, N, String> listState = mock(InternalListState.class);
        ListStateDescriptor<String> listStateDescriptor =
                new ListStateDescriptor<>("list", String.class);
        InternalKvState<K, N, ?> latencyTrackingState =
                LatencyTrackingStateFactory.createStateAndWrapWithLatencyTrackingIfEnabled(
                        listState, listStateDescriptor, getLatencyTrackingStateConfig());
        if (enableLatencyTracking) {
            assertThat(latencyTrackingState).isInstanceOf(LatencyTrackingListState.class);
        } else {
            assertThat(latencyTrackingState).isEqualTo(listState);
        }
    }