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

jio.test.stub.httpserver.PatchStub 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 PATCH HTTP request.
 */
public final class PatchStub extends ReqHandlerStub {

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

  /**
   * Creates a PATCH 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 PATCH stub.
   */
  public static PatchStub of(final BodyStub body,
                             final StatusCodeStub statusCode,
                             final HeadersStub headers
                            ) {
    return new PatchStub(body,
                         statusCode,
                         headers);
  }

  /**
   * Creates a PATCH 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 PATCH stub.
   */
  public static PatchStub of(final BodyStub body,
                             final StatusCodeStub statusCode
                            ) {
    return new PatchStub(body,
                         statusCode,
                         HeadersStub.EMPTY);
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy