public static int checkBackupCount(int newBackupCount, int currentAsyncBackupCount) {
        if (newBackupCount < 0) {
            throw new IllegalArgumentException("backup-count can't be smaller than 0");
        }

        if (currentAsyncBackupCount < 0) {
            throw new IllegalArgumentException("async-backup-count can't be smaller than 0");
        }

        if (newBackupCount > MAX_BACKUP_COUNT) {
            throw new IllegalArgumentException("backup-count can't be larger than than " + MAX_BACKUP_COUNT);
        }

        if (newBackupCount + currentAsyncBackupCount > MAX_BACKUP_COUNT) {
            throw new IllegalArgumentException("the sum of backup-count and async-backup-count can't be larger than than "
                    + MAX_BACKUP_COUNT);
        }

        return newBackupCount;
    }
@Test
    public void checkBackupCount() {
        checkBackupCount(-1, 0, false);
        checkBackupCount(-1, -1, false);
        checkBackupCount(0, -1, false);
        checkBackupCount(0, 0, true);
        checkBackupCount(0, 1, true);
        checkBackupCount(1, 1, true);
        checkBackupCount(2, 1, true);
        checkBackupCount(1, 2, true);
        checkBackupCount(MAX_BACKUP_COUNT, 0, true);
        checkBackupCount(0, MAX_BACKUP_COUNT, true);
        checkBackupCount(MAX_BACKUP_COUNT, 1, false);
        checkBackupCount(MAX_BACKUP_COUNT + 1, 0, false);
        checkBackupCount(0, MAX_BACKUP_COUNT + 1, false);
    }