public Optional<Integer> leaderOpt() {
        return leader == LeaderAndIsr.NO_LEADER ? Optional.empty() : Optional.of(leader);
    }
@Test
    public void testLeaderOpt() {
        LeaderAndIsr leaderAndIsr = new LeaderAndIsr(2, Arrays.asList(1, 2, 3));

        assertEquals(2, leaderAndIsr.leaderOpt().orElse(0));
    }