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 TypeMethodDescriptionboolean
Compares this ValidationTask to the specified object for equality.int
hashCode()
Returns a hash code value for this object.boolean
Checks if the response status code and body match the expected criteria.com.fasterxml.jackson.databind.JsonNode
reqBody()
Returns the value of thereqBody
record component.Returns the value of thereqHeaders
record component.Returns the value of thereqMethod
record component.reqURL()
Returns the value of thereqURL
record component.final String
toString()
Returns a string representation of this record class.Returns the value of thevalidBody
record component.int
Returns the value of thevalidStatusCode
record 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:
true
if the status code matches and the body contains the expected substring,false
otherwise.
-
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 thereqMethod
record component.- Returns:
- the value of the
reqMethod
record component
-
reqURL
Returns the value of thereqURL
record component.- Returns:
- the value of the
reqURL
record component
-
reqHeaders
Returns the value of thereqHeaders
record component.- Returns:
- the value of the
reqHeaders
record component
-
reqBody
public com.fasterxml.jackson.databind.JsonNode reqBody()Returns the value of thereqBody
record component.- Returns:
- the value of the
reqBody
record component
-
validStatusCode
public int validStatusCode()Returns the value of thevalidStatusCode
record component.- Returns:
- the value of the
validStatusCode
record component
-
validBody
Returns the value of thevalidBody
record component.- Returns:
- the value of the
validBody
record component
-