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 testTrackMapState() throws Exception {
        InternalMapState<K, N, String, Long> mapState = mock(InternalMapState.class);
        MapStateDescriptor<String, Long> mapStateDescriptor =
                new MapStateDescriptor<>("map", String.class, Long.class);
        InternalKvState<K, N, ?> latencyTrackingState =
                LatencyTrackingStateFactory.createStateAndWrapWithLatencyTrackingIfEnabled(
                        mapState, mapStateDescriptor, getLatencyTrackingStateConfig());
        if (enableLatencyTracking) {
            assertThat(latencyTrackingState).isInstanceOf(LatencyTrackingMapState.class);
        } else {
            assertThat(latencyTrackingState).isEqualTo(mapState);
        }
    }