@Override
  public void poll(long timeoutMs, List<NetworkSend> sends) throws IOException {
    if (state == MockSelectorState.ThrowExceptionOnPoll) {
      throw new IOException("Mock exception on poll");
    }
    disconnected = new ArrayList<>();
    if (state == MockSelectorState.FailConnectionInitiationOnPoll) {
      disconnected.addAll(nextConnected);
      connected = new ArrayList<>();
      nextConnected = new ArrayList<>();
    } else if (state != MockSelectorState.IdlePoll) {
      connected = nextConnected;
      nextConnected = new ArrayList<>();
    }
    disconnected.addAll(delayedFailPassedList);
    delayedFailPassedList.clear();
    delayedFailPassedList.addAll(delayedFailFreshList);
    delayedFailFreshList.clear();
    disconnected.addAll(closedConnections);
    this.sends = sends;
    if (sends != null) {
      for (NetworkSend send : sends) {
        MockSend mockSend = (MockSend) send.getPayload();
        if (state == MockSelectorState.DisconnectOnSend) {
          disconnected.add(send.getConnectionId());
        } else if (!closedConnections.contains(send.getConnectionId())) {
          receives.add(new NetworkReceive(send.getConnectionId(),
              new MockBoundedNettyByteBufReceive(mockSend.getCorrelationId()), new MockTime()));
          mockSend.writeTo(new ByteBufferChannel(ByteBuffer.allocate(MockSend.SEND_SIZE)));
          if (mockSend.isSendComplete()) {
            mockSend.release();
          }
        }
      }
    }
    closedConnections.clear();
  }
Mocks sending and polling. Creates a response for every send to be returned after the next poll,
with the correlation id in the Send, unless beBad state is on. If beBad is on,
all sends will result in disconnections.
@param timeoutMs Ignored.
@param sends The list of new sends.
ambry-network/src/test/java/com/github/ambry/network/SocketNetworkClientTest.java