public void mockNextInt(int expectedBound, int returnValue) {
        this.nextIntFunction = b -> {
            if (b == expectedBound)
                return OptionalInt.of(returnValue);
            else
                return OptionalInt.empty();
        };
    }
A Random instance that makes it easy to modify the behavior of certain methods for test purposes.
raft/src/test/java/org/apache/kafka/raft/MockableRandom.java