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

jio.test.stub.httpserver.DeleteStub 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.HttpHandler;

import static java.util.Objects.requireNonNull;

/**
 * Stub that stands in for the {@link HttpHandler} of a DELETE HTTP request.
 */
public final class DeleteStub extends ReqHandlerStub {

  private DeleteStub(final BodyStub body,
                     final StatusCodeStub statusCode,
                     final HeadersStub headers
                    ) {
    super(requireNonNull(body),
          requireNonNull(statusCode),
          requireNonNull(headers),
          "delete"
         );
  }


  /**
   * Creates a DELETE handler stub that builds the HTTP response from the given body, status code, and headers stubs.
   *
   * @param body       The body response stub.
   * @param statusCode The status code response stub.
   * @param headers    The headers response stub.
   * @return A delete stub.
   */
  public static DeleteStub of(final BodyStub body,
                              final StatusCodeStub statusCode,
                              final HeadersStub headers
                             ) {
    return new DeleteStub(body,
                          statusCode,
                          headers);
  }

  /**
   * Creates a DELETE handler stub that builds the HTTP response from the given body and status code stubs.
   *
   * @param body       The body response stub.
   * @param statusCode The status code response stub.
   * @return A delete stub.
   */
  public static DeleteStub of(final BodyStub body,
                              final StatusCodeStub statusCode
                             ) {
    return new DeleteStub(body,
                          statusCode,
                          HeadersStub.EMPTY);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy