All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jio.test.stub.httpserver.HeadersStub Maven / Gradle / Ivy

Go to download

JIO test library based on Property Based Testing and Java Flight Recording Debuggers

There is a newer version: 3.0.0-RC2
Show newest version
package jio.test.stub.httpserver;

import com.sun.net.httpserver.Headers;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * A stub that stands in for the response {@link Headers} of an HTTP request.
 */
public non-sealed interface HeadersStub extends HttpRespStub {

  /**
   * An empty headers stub that always sets empty headers as the response headers.
   */
  HeadersStub EMPTY = n -> reqBody -> uri -> headers -> new Headers();

  /**
   * Creates a headers stub that always sets the specified map as the response headers.
   *
   * @param map The map of headers to be set as response headers.
   * @return A header stub that sets the specified headers.
   * @throws NullPointerException if the provided map is null.
   */
  static HeadersStub cons(Map> map) {
    Headers respHeaders = new Headers();
    respHeaders.putAll(Objects.requireNonNull(map));
    return n -> reqBody -> uri -> reqHeaders -> respHeaders;
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy