@Override
    public void setPermits(int permits) {
        get(setPermitsAsync(permits));
    }
@Test
    public void testSetPermits() throws InterruptedException {
        RPermitExpirableSemaphore s = redisson.getPermitExpirableSemaphore("test");
        s.setPermits(10);
        assertThat(s.getPermits()).isEqualTo(10);
        assertThat(s.availablePermits()).isEqualTo(10);
        assertThat(s.acquiredPermits()).isEqualTo(0);

        // attempts to set available permits fail
        assertThat(s.trySetPermits(15)).isFalse();
        assertThat(s.getPermits()).isEqualTo(10);
        assertThat(s.availablePermits()).isEqualTo(10);
        assertThat(s.acquiredPermits()).isEqualTo(0);

        // attempts to set max permits succeeds
        s.setPermits(15);
        assertThat(s.getPermits()).isEqualTo(15);
        assertThat(s.availablePermits()).isEqualTo(15);
        assertThat(s.acquiredPermits()).isEqualTo(0);

        // setting to existing value succeeds
        s.setPermits(15);
        assertThat(s.getPermits()).isEqualTo(15);
        assertThat(s.availablePermits()).isEqualTo(15);
        assertThat(s.acquiredPermits()).isEqualTo(0);

        // decreasing max permits succeeds
        s.setPermits(5);
        assertThat(s.getPermits()).isEqualTo(5);
        assertThat(s.availablePermits()).isEqualTo(5);
        assertThat(s.acquiredPermits()).isEqualTo(0);

        // changing the max after acquiring permits succeeds
        String acquire1 = s.tryAcquire(200, 1000, TimeUnit.MILLISECONDS);
        assertThat(acquire1).isNotNull();
        String acquire2 = s.tryAcquire(200, 1000, TimeUnit.MILLISECONDS);
        assertThat(acquire2).isNotNull();
        String acquire3 = s.tryAcquire(200, 1000, TimeUnit.MILLISECONDS);
        assertThat(acquire3).isNotNull();

        assertThat(s.getPermits()).isEqualTo(5);
        assertThat(s.availablePermits()).isEqualTo(2);
        assertThat(s.acquiredPermits()).isEqualTo(3);

        // decreasing the max to the number of claimed permits is allowed
        s.setPermits(3);
        assertThat(s.getPermits()).isEqualTo(3);
        assertThat(s.availablePermits()).isEqualTo(0);
        assertThat(s.acquiredPermits()).isEqualTo(3);

        // decreasing the max to below the number of claimed permits is allowed
        // and results in a negative number of available permits
        s.setPermits(2);
        assertThat(s.getPermits()).isEqualTo(2);
        assertThat(s.availablePermits()).isEqualTo(-1);
        assertThat(s.acquiredPermits()).isEqualTo(3);
    }