class MockDispatcher extends Dispatcher {

  private final Map<ServerRequest, Queue<ServerResponse>> responses;
  private final Collection<WebSocketSession> webSocketSessions = new ConcurrentLinkedQueue<>();

  public MockDispatcher(Map<ServerRequest, Queue<ServerResponse>> responses) {
    this.responses = responses;
  }

  @Override
  public MockResponse dispatch(RecordedRequest request) {
    for (WebSocketSession webSocketSession : webSocketSessions) {
      webSocketSession.dispatch(request);
    }

    HttpMethod method = HttpMethod.valueOf(request.getMethod());
    String path = request.getPath();
    SimpleRequest key = new SimpleRequest(method, path);
    SimpleRequest keyForAnyMethod = new SimpleRequest(path);
    if (responses.containsKey(key)) {
      Queue<ServerResponse> queue = responses.get(key);
      return handleResponse(queue.peek(), queue, request);
    } else if (responses.containsKey(keyForAnyMethod)) {
      Queue<ServerResponse> queue = responses.get(keyForAnyMethod);
      return handleResponse(queue.peek(), queue, request);
    }
    return new MockResponse().setResponseCode(404);
  }

  private MockResponse handleResponse(ServerResponse response, Queue<ServerResponse> queue, RecordedRequest request) {<FILL_FUNCTION_BODY>}

  @Override
  public void shutdown() {
    webSocketSessions.forEach(WebSocketSession::shutdown);
    super.shutdown();
  }
}

    if (response == null) {
      return new MockResponse().setResponseCode(404);
    } else if (!response.isRepeatable()) {
      queue.remove();
    }
    if (response instanceof SimpleResponse) {
      SimpleResponse simpleResponse = (SimpleResponse) response;
      if (simpleResponse.getWebSocketSession() != null) {
        webSocketSessions.add(simpleResponse.getWebSocketSession());
      }
    }
    return response.toMockResponse(request);
  
<no_super_class>