@VisibleForTesting
    boolean skipUpdate(int newSize) {
        if (newSize == lastBufferSize) {
            return true;
        }

        // According to logic of this class newSize can not be less than min or greater than max
        // buffer size but if considering this method independently the behaviour for the small or
        // big value should be the same as for min and max buffer size correspondingly.
        if (newSize <= minBufferSize || newSize >= maxBufferSize) {
            return false;
        }

        int delta = (int) (lastBufferSize * bufferDebloatThresholdFactor);
        return Math.abs(newSize - lastBufferSize) < delta;
    }
@Test
    void testSkipUpdate() {
        int maxBufferSize = 32768;
        int minBufferSize = 256;
        double threshold = 0.3;
        BufferDebloater bufferDebloater =
                testBufferDebloater()
                        .withDebloatTarget(1000)
                        .withBufferSize(minBufferSize, maxBufferSize)
                        // 30 % Threshold.
                        .withThresholdPercentages((int) (threshold * 100))
                        .getBufferDebloater();

        int currentBufferSize = maxBufferSize / 2;

        OptionalInt optionalInt = bufferDebloater.recalculateBufferSize(currentBufferSize, 1);
        assertThat(optionalInt).isPresent().hasValue(currentBufferSize);

        // It is true because less than threshold.
        assertThat(bufferDebloater.skipUpdate(currentBufferSize)).isTrue();
        assertThat(bufferDebloater.skipUpdate(currentBufferSize - 1)).isTrue();
        assertThat(bufferDebloater.skipUpdate(currentBufferSize + 1)).isTrue();

        assertThat(
                        bufferDebloater.skipUpdate(
                                currentBufferSize - (int) (currentBufferSize * threshold) + 1))
                .isTrue();
        assertThat(
                        bufferDebloater.skipUpdate(
                                currentBufferSize + (int) (currentBufferSize * threshold) - 1))
                .isTrue();

        // It is false because it reaches threshold.
        assertThat(
                        bufferDebloater.skipUpdate(
                                currentBufferSize - (int) (currentBufferSize * threshold)))
                .isFalse();
        assertThat(
                        bufferDebloater.skipUpdate(
                                currentBufferSize + (int) (currentBufferSize * threshold)))
                .isFalse();
        assertThat(bufferDebloater.skipUpdate(minBufferSize + 1)).isFalse();
        assertThat(bufferDebloater.skipUpdate(minBufferSize)).isFalse();
        assertThat(bufferDebloater.skipUpdate(maxBufferSize - 1)).isFalse();
        assertThat(bufferDebloater.skipUpdate(maxBufferSize)).isFalse();

        // Beyond the min and max size is always false.
        assertThat(bufferDebloater.skipUpdate(maxBufferSize + 1)).isFalse();
        assertThat(bufferDebloater.skipUpdate(minBufferSize - 1)).isFalse();
    }