### Question:
Replicator implements ThreadId.OnError { long getNextSendIndex() { if (this.inflights.isEmpty()) { return this.nextIndex; } if (this.inflights.size() > this.raftOptions.getMaxReplicatorInflightMsgs()) { return -1L; } if (this.rpcInFly != null && this.rpcInFly.isSendingLogEntries()) { return this.rpcInFly.startIndex + this.rpcInFly.count; } return -1L; } Replicator(final ReplicatorOptions replicatorOptions, final RaftOptions raftOptions); @OnlyForTest PriorityQueue<RpcResponse> getPendingResponses(); static ThreadId start(final ReplicatorOptions opts, final RaftOptions raftOptions); static void waitForCaughtUp(final ThreadId id, final long maxMargin, final long dueTime,
                                       final CatchUpClosure done); @Override String toString(); @Override void onError(final ThreadId id, final Object data, final int errorCode); static void sendHeartbeat(final ThreadId id, final RpcResponseClosure<AppendEntriesResponse> closure); static boolean stop(final ThreadId id); static boolean join(final ThreadId id); static long getLastRpcSendTimestamp(final ThreadId id); static boolean transferLeadership(final ThreadId id, final long logIndex); static boolean stopTransferLeadership(final ThreadId id); static boolean sendTimeoutNowAndStop(final ThreadId id, final int timeoutMs); static long getNextIndex(final ThreadId id);  }### Answer:
@Test public void testGetNextSendIndex() { final Replicator r = getReplicator(); assertEquals(-1, r.getNextSendIndex()); r.resetInflights(); assertEquals(11, r.getNextSendIndex()); mockSendEntries(3); r.sendEntries(); assertEquals(14, r.getNextSendIndex()); }