Record Class ValidationTask

java.lang.Object
java.lang.Record
cf.maybelambda.httpvalidator.springboot.model.ValidationTask

public record ValidationTask(FormSubmitEvent.MethodType reqMethod, String reqURL, List<String> reqHeaders, com.fasterxml.jackson.databind.JsonNode reqBody, int validStatusCode, String validBody) extends Record
Represents a validation task with HTTP request details and expected response criteria.
  • Constructor Details

    • ValidationTask

      public ValidationTask(FormSubmitEvent.MethodType reqMethod, String reqURL, List<String> reqHeaders, com.fasterxml.jackson.databind.JsonNode reqBody, int validStatusCode, String validBody)
      Constructor for ValidationTask. Ensures that none of the parameters are null.
      Parameters:
      reqMethod - The HTTP request method, GET or POST.
      reqURL - The URL for the HTTP request.
      reqHeaders - The headers for the HTTP request.
      reqBody - The JSON body for a POST request.
      validStatusCode - The expected status code for a valid response.
      validBody - The expected substring in the response body for a valid response.
      Throws:
      NullPointerException - if any argument is null.
  • Method Details

    • isValid

      public boolean isValid(int statusCode, String body)
      Checks if the response status code and body match the expected criteria.

      This method validates the response by comparing the status code and checking if the response body contains the expected substring.

      Parameters:
      statusCode - The status code of the HTTP response.
      body - The body of the HTTP response.
      Returns:
      true if the status code matches and the body contains the expected substring, false otherwise.
    • equals

      public boolean equals(Object o)
      Compares this ValidationTask to the specified object for equality.

      The comparison is based on the request method, request URL, request headers, request body, valid status code, and valid response body.

      Specified by:
      equals in class Record
      Parameters:
      o - The object to compare with this ValidationTask.
      Returns:
      true if the specified object is equal to this ValidationTask; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • reqMethod

      public FormSubmitEvent.MethodType reqMethod()
      Returns the value of the reqMethod record component.
      Returns:
      the value of the reqMethod record component
    • reqURL

      public String reqURL()
      Returns the value of the reqURL record component.
      Returns:
      the value of the reqURL record component
    • reqHeaders

      public List<String> reqHeaders()
      Returns the value of the reqHeaders record component.
      Returns:
      the value of the reqHeaders record component
    • reqBody

      public com.fasterxml.jackson.databind.JsonNode reqBody()
      Returns the value of the reqBody record component.
      Returns:
      the value of the reqBody record component
    • validStatusCode

      public int validStatusCode()
      Returns the value of the validStatusCode record component.
      Returns:
      the value of the validStatusCode record component
    • validBody

      public String validBody()
      Returns the value of the validBody record component.
      Returns:
      the value of the validBody record component