@Override
    public void setMaxParallelism(int maxParallelism) {
        maxParallelism = normalizeAndCheckMaxParallelism(maxParallelism);

        Optional<String> validationResult = rescaleMaxValidator.apply(maxParallelism);
        if (validationResult.isPresent()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Rescaling max parallelism from %s to %s is not allowed: %s",
                            this.maxParallelism, maxParallelism, validationResult.get()));
        }

        this.maxParallelism = maxParallelism;
    }
@Test
    void setMaxInvalid() {
        DefaultVertexParallelismInfo info =
                new DefaultVertexParallelismInfo(1, 1, (max) -> Optional.of("not valid"));

        assertThatThrownBy(() -> info.setMaxParallelism(4))
                .withFailMessage("not valid")
                .isInstanceOf(IllegalArgumentException.class);
    }