class KubernetesServer extends ExternalResource {

  private KubernetesMockServer mock;
  private NamespacedKubernetesClient client;
  private final boolean https;
  // In this mode the mock web server will store, read, update and delete
  // kubernetes resources using an in memory map and will appear as a real api
  // server.
  private final boolean crudMode;
  private final InetAddress address;
  private final int port;
  private final List<CustomResourceDefinitionContext> crdContextList;

  public KubernetesServer() {
    this(true);
  }

  public KubernetesServer(boolean https) {
    this(https, false);
  }

  public KubernetesServer(boolean https, boolean crudMode) {
    this(https, crudMode, InetAddress.getLoopbackAddress(), 0, Collections.emptyList());
  }

  public KubernetesServer(boolean https, boolean crudMode, List<CustomResourceDefinitionContext> crdContextList) {
    this(https, crudMode, InetAddress.getLoopbackAddress(), 0, crdContextList);
  }

  public KubernetesServer(boolean https, boolean crudMode, InetAddress address, int port,
      List<CustomResourceDefinitionContext> crdContextList) {
    this.https = https;
    this.crudMode = crudMode;
    this.address = address;
    this.port = port;
    this.crdContextList = crdContextList;
  }

  @Override
  public void before() {<FILL_FUNCTION_BODY>}

  @Override
  public void after() {
    mock.destroy();
    client.close();
  }

  public NamespacedKubernetesClient getClient() {
    return client;
  }

  public MockServerExpectation expect() {
    return mock.expect();
  }

  @Deprecated
  public <T> void expectAndReturnAsJson(String path, int code, T body) {
    expect().withPath(path).andReturn(code, body).always();
  }

  @Deprecated
  public void expectAndReturnAsString(String path, int code, String body) {
    expect().withPath(path).andReturn(code, body).always();
  }

  @Deprecated
  public <T> void expectAndReturnAsJson(String method, String path, int code, T body) {
    expect().withPath(path).andReturn(code, body).always();
  }

  @Deprecated
  public void expectAndReturnAsString(String method, String path, int code, String body) {
    expect().withPath(path).andReturn(code, body).always();
  }

  public KubernetesMockServer getKubernetesMockServer() {
    return mock;
  }

  public RecordedRequest getLastRequest() throws InterruptedException {
    return mock.getLastRequest();
  }
}

    final Map<ServerRequest, Queue<ServerResponse>> responses = new HashMap<>();
    mock = crudMode
        ? new KubernetesMockServer(new Context(), new MockWebServer(), responses,
            new KubernetesMixedDispatcher(responses, crdContextList), https)
        : new KubernetesMockServer(https);
    mock.init(address, port);
    client = mock.createClient();
  
<no_super_class>