RaftActorLeadershipTransferCohort { @VisibleForTesting void doTransfer() { RaftActorBehavior behavior = raftActor.getCurrentBehavior(); if (behavior instanceof Leader) { isTransferring = true; ((Leader)behavior).transferLeadership(this); } else { LOG.debug("{}: No longer the leader - skipping transfer", raftActor.persistenceId()); finish(true); } } RaftActorLeadershipTransferCohort(final RaftActor raftActor);   RaftActorLeadershipTransferCohort(final RaftActor raftActor, final @Nullable String requestedFollowerId); void abortTransfer(); void transferComplete(); Optional<String> getRequestedFollowerId();  }
@Test public void testNotLeaderOnDoTransfer() { setup("testNotLeaderOnDoTransfer"); cohort.doTransfer(); verify(onComplete).onSuccess(mockRaftActor.self()); }