@Override
    public void onAccepting(SelectableChannel channel) {
        throttleIfAnyThresholdIsExceeded();
    }
@Test
    void throttles_when_any_resource_check_exceeds_configured_threshold() {
        var runtime = mock(ConnectionThrottler.Jvm.class);
        when(runtime.maxMemory()).thenReturn(100l);
        RateStatistic rateStatistic = new RateStatistic(1, TimeUnit.HOURS);
        MockScheduler scheduler = new MockScheduler();
        ConnectorConfig.Throttling config = new ConnectorConfig.Throttling(new ConnectorConfig.Throttling.Builder()
                .maxHeapUtilization(0.8)
                .maxAcceptRate(1));

        AbstractConnector connector = mock(AbstractConnector.class);

        ConnectionThrottler throttler = new ConnectionThrottler(runtime, rateStatistic, scheduler, connector, config);

        // Heap utilization above configured threshold, but connection rate below threshold.
        when(runtime.freeMemory()).thenReturn(10l);
        when(connector.isAccepting()).thenReturn(true);
        throttler.onAccepting(null);
        assertNotNull(scheduler.task);
        verify(connector).setAccepting(false);

        // Heap utilization below threshold, but connection rate above threshold.
        when(runtime.freeMemory()).thenReturn(80l);
        rateStatistic.record();
        rateStatistic.record(); // above accept rate limit (2 > 1)
        scheduler.task.run(); // run unthrottleIfBelowThresholds()
        verify(connector, times(1)).setAccepting(anyBoolean()); // verify setAccepting has not been called any mores times

        // Both heap utilization and accept rate below threshold
        when(runtime.freeMemory()).thenReturn(80l);
        when(connector.isAccepting()).thenReturn(false);
        rateStatistic.reset();
        scheduler.task.run(); // run unthrottleIfBelowThresholds()
        verify(connector).setAccepting(true);

        // Both heap utilization and accept rate below threshold
        when(connector.isAccepting()).thenReturn(true);
        when(runtime.freeMemory()).thenReturn(80l);
        rateStatistic.record();
        throttler.onAccepting(null);
        verify(connector, times(2)).setAccepting(anyBoolean()); // verify setAccepting has not been called any mores times
    }