@Test(timeout = 30_000)
public void testLeaderElection() {

    Iterator<ClusterMembershipSnapshot> eventIterator = resolver.resolve().toIterable().iterator();
    eventIterator.next();
    // Make member 1 the leader
    memberResolver1.setAsLeader(MEMBER_1);
    Optional<ClusterMembershipRevision<ClusterMemberLeadership>> firstLeader = eventIterator.next().getLeaderRevision();
    assertThat(firstLeader).isPresent();
    assertThat(firstLeader.get().getCurrent().getMemberId()).isEqualTo(MEMBER_1.getCurrent().getMemberId());
    // Make member 2 the leader
    memberResolver1.setAsLeader(MEMBER_2);
    Optional<ClusterMembershipRevision<ClusterMemberLeadership>> secondLeader = eventIterator.next().getLeaderRevision();
    assertThat(secondLeader).isPresent();
    assertThat(secondLeader.get().getCurrent().getMemberId()).isEqualTo(MEMBER_2.getCurrent().getMemberId());
}