RaftActorLeadershipTransferCohort { void onNewLeader(final String newLeader) { if (newLeader != null && newLeaderTimer != null) { LOG.debug("{}: leader changed to {}", raftActor.persistenceId(), newLeader); newLeaderTimer.cancel(); finish(true); } } RaftActorLeadershipTransferCohort(final RaftActor raftActor);   RaftActorLeadershipTransferCohort(final RaftActor raftActor, final @Nullable String requestedFollowerId); void abortTransfer(); void transferComplete(); Optional<String> getRequestedFollowerId();  }
@Test public void testOnNewLeader() { setup("testOnNewLeader"); cohort.setNewLeaderTimeoutInMillis(20000); cohort.onNewLeader("new-leader"); verify(onComplete, never()).onSuccess(mockRaftActor.self()); cohort.transferComplete(); cohort.onNewLeader(null); verify(onComplete, never()).onSuccess(mockRaftActor.self()); cohort.onNewLeader("new-leader"); verify(onComplete).onSuccess(mockRaftActor.self()); }