### Question:
RaftReplicator implements Replicator, LeaderListener { @Override public Future<Object> replicate( ReplicatedContent command, boolean trackResult ) throws ReplicationFailureException { MemberId currentLeader = leaderProvider.currentLeader(); if ( currentLeader == null ) { throw new ReplicationFailureException( "Replication aborted since no leader was available" ); } return replicate0( command, trackResult, currentLeader ); } RaftReplicator( LeaderLocator leaderLocator, MemberId me, Outbound<MemberId,RaftMessages.RaftMessage> outbound, LocalSessionPool sessionPool,
            ProgressTracker progressTracker, TimeoutStrategy progressTimeoutStrategy, long availabilityTimeoutMillis, AvailabilityGuard availabilityGuard,
            LogProvider logProvider, LocalDatabase localDatabase, Monitors monitors ); @Override Future<Object> replicate( ReplicatedContent command, boolean trackResult ); @Override void onLeaderSwitch( LeaderInfo leaderInfo );  }### Answer:
@Test void shouldFailIfNoLeaderIsAvailable() { CapturingProgressTracker capturedProgress = new CapturingProgressTracker(); CapturingOutbound<RaftMessages.RaftMessage> outbound = new CapturingOutbound<>(); RaftReplicator replicator = getReplicator( outbound, capturedProgress, new Monitors() ); ReplicatedInteger content = ReplicatedInteger.valueOf( 5 ); assertThrows( ReplicationFailureException.class, () -> replicator.replicate( content, true ) ); }