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 Summary
ConstructorsConstructorDescriptionValidationTask(FormSubmitEvent.MethodType reqMethod, String reqURL, List<String> reqHeaders, com.fasterxml.jackson.databind.JsonNode reqBody, int validStatusCode, String validBody) Constructor for ValidationTask. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this ValidationTask to the specified object for equality.inthashCode()Returns a hash code value for this object.booleanChecks if the response status code and body match the expected criteria.com.fasterxml.jackson.databind.JsonNodereqBody()Returns the value of thereqBodyrecord component.Returns the value of thereqHeadersrecord component.Returns the value of thereqMethodrecord component.reqURL()Returns the value of thereqURLrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalidBodyrecord component.intReturns the value of thevalidStatusCoderecord component.
-
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
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:
trueif the status code matches and the body contains the expected substring,falseotherwise.
-
equals
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.
-
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. -
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. -
reqMethod
Returns the value of thereqMethodrecord component.- Returns:
- the value of the
reqMethodrecord component
-
reqURL
Returns the value of thereqURLrecord component.- Returns:
- the value of the
reqURLrecord component
-
reqHeaders
Returns the value of thereqHeadersrecord component.- Returns:
- the value of the
reqHeadersrecord component
-
reqBody
public com.fasterxml.jackson.databind.JsonNode reqBody()Returns the value of thereqBodyrecord component.- Returns:
- the value of the
reqBodyrecord component
-
validStatusCode
public int validStatusCode()Returns the value of thevalidStatusCoderecord component.- Returns:
- the value of the
validStatusCoderecord component
-
validBody
Returns the value of thevalidBodyrecord component.- Returns:
- the value of the
validBodyrecord component
-