### Question:
AppendEntriesRequestProcessor extends NodeRequestProcessor<AppendEntriesRequest> implements
                                                                                             ConnectionClosedEventListener { void sendSequenceResponse(final String groupId, final String peerId, final int seq, final RpcContext rpcCtx, final Message msg) { final Connection connection = rpcCtx.getConnection(); final PeerRequestContext ctx = getPeerRequestContext(groupId, peerId, connection); final PriorityQueue<SequenceMessage> respQueue = ctx.responseQueue; assert (respQueue != null); synchronized (Utils.withLockObject(respQueue)) { respQueue.add(new SequenceMessage(rpcCtx, msg, seq)); if (!ctx.hasTooManyPendingResponses()) { while (!respQueue.isEmpty()) { final SequenceMessage queuedPipelinedResponse = respQueue.peek(); if (queuedPipelinedResponse.sequence != getNextRequiredSequence(groupId, peerId, connection)) { break; } respQueue.remove(); try { queuedPipelinedResponse.sendResponse(); } finally { getAndIncrementNextRequiredSequence(groupId, peerId, connection); } } } else { LOG.warn("Closed connection to peer {}/{}, because of too many pending responses, queued={}, max={}", ctx.groupId, peerId, respQueue.size(), ctx.maxPendingResponses); connection.close(); removePeerRequestContext(groupId, peerId); } } } AppendEntriesRequestProcessor(final Executor executor); @Override Message processRequest0(final RaftServerService service, final AppendEntriesRequest request,
                                   final RpcRequestClosure done); @Override String interest(); @Override ExecutorSelector executorSelector(); void destroy(); @Override void onClosed(final String remoteAddress, final Connection conn);  }### Answer:
@Test public void testSendSequenceResponse() { mockNode(); final RpcContext asyncContext = Mockito.mock(RpcContext.class); final AppendEntriesRequestProcessor processor = (AppendEntriesRequestProcessor) newProcessor(); final PingRequest msg = TestUtils.createPingRequest(); processor.sendSequenceResponse(groupId, peerIdStr, 1, asyncContext, msg); Mockito.verify(asyncContext, Mockito.never()).sendResponse(msg); processor.sendSequenceResponse(groupId, peerIdStr, 0, asyncContext, msg); Mockito.verify(asyncContext, Mockito.times(2)).sendResponse(msg); }