UNPKG

@gatling.io/core

Version:

Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).

188 lines (187 loc) 7.12 kB
import { Session, SessionTo } from "../session"; import { CheckBuilderFinal } from "./final"; import JvmCheckBuilderValidate = io.gatling.javaapi.core.CheckBuilder$Validate; /** * Step 2 of the Check DSL where we define how to validate the extracted value. Immutable, so all * methods return a new occurrence and leave the original unmodified. * * @typeParam X - the type of the extracted value */ export interface CheckBuilderValidate<X> extends CheckBuilderFinal { /** * Transform the extracted value * * @param f - the transformation function * @typeParam X2 - the transformed value * @returns a new CheckBuilderValidate */ transform<X2>(f: (x: X) => X2): CheckBuilderValidate<X2>; /** * Transform the extracted value, whith access to the current Session * * @param f - the transformation function * @typeParam X2 - the transformed value * @returns a new CheckBuilderValidate */ transformWithSession<X2>(f: (x: X, session: Session) => X2): CheckBuilderValidate<X2>; /** * Provide a default value if the check wasn't able to extract anything * * @param value - the default value or a function returning the default value * @returns a new Validate */ withDefault(value: X | ((session: Session) => X)): CheckBuilderValidate<X>; /** * Provide a default Gatling Expression Language value if the check wasn't able to extract * anything * * @param value - the default value as a Gatling Expression Language String * @returns a new Validate */ withDefaultEL(value: string): CheckBuilderValidate<X>; /** * Provide a custom validation strategy * * @param name - the name of the validation, in case of a failure * @param f - the custom validation function, must throw to trigger a failure * @returns a new CheckBuilderFinal */ validate(name: string, f: (x: X, session: Session) => X): CheckBuilderFinal; /** * Validate the extracted value is equal to an expected value * * @param expected - the expected value or a function returning the expected value * @returns a new CheckBuilderFinal */ is(expected: X | ((session: Session) => X)): CheckBuilderFinal; /** * Validate the extracted value is equal to an expected value, passed as a Gatling Expression * Language String * * @param expected - the expected value as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ isEL(expected: string): CheckBuilderFinal; /** * Validate the extracted value is null * * @returns a new CheckBuilderFinal */ isNull(): CheckBuilderFinal; /** * Validate the extracted value is not an expected value * * @param expected - the unexpected value or a function returning the unexpected value * @returns a new CheckBuilderFinal */ not(expected: X | ((session: Session) => X)): CheckBuilderFinal; /** * Validate the extracted value is not an expected value, passed as a Gatling Expression * Language String * * @param expected - the unexpected value as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ notEL(expected: string): CheckBuilderFinal; /** * Validate the extracted value is not null * * @returns a new CheckBuilderFinal */ notNull(): CheckBuilderFinal; /** * Validate the extracted value belongs to an expected set * * @param expectedOrFunction - either a single expected value or a function returning an array of expected values * @param additionalValues - additional expected values (ignored if expectedOrFunction is a function) * @returns a new Final */ in(expectedOrFunction: X | SessionTo<X[]>, ...additionalValues: X[]): CheckBuilderFinal; /** * Validate the extracted value belongs to an expected set, passed as a Gatling Expression * Language String * * @param expected - the set of possible values, as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ inEL(expected: string): CheckBuilderFinal; /** * Validate the check was able to extract any value * * @returns a new CheckBuilderFinal */ exists(): CheckBuilderFinal; /** * Validate the check was not able to extract any value * * @returns a new CheckBuilderFinal */ notExists(): CheckBuilderFinal; /** * Make the check is successful whenever it was able to extract something or not * * @returns a new CheckBuilderFinal */ optional(): CheckBuilderFinal; /** * Validate the extracted value is less than a given value * * @param value - the value or a function returning the value * @returns a new CheckBuilderFinal */ lt(value: X | ((session: Session) => X)): CheckBuilderFinal; /** * Validate the extracted value is less than a given value, passed as a Gatling Expression * Language String * * @param value - the value, as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ ltEL(value: string): CheckBuilderFinal; /** * Validate the extracted value is less than or equal to a given value * * @param value - the value or a function returning the value * @returns a new CheckBuilderFinal */ lte(value: X | ((session: Session) => X)): CheckBuilderFinal; /** * Validate the extracted value is less than or equal to a given value, passed as a Gatling * Expression Language String * * @param value - the value, as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ lteEL(value: string): CheckBuilderFinal; /** * Validate the extracted value is greater than a given value * * @param value - the value or a function returning the value * @returns a new CheckBuilderFinal */ gt(value: X | ((session: Session) => X)): CheckBuilderFinal; /** * Validate the extracted value is greater than a given value, passed as a Gatling Expression * Language String * * @param value - the value, as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ gtEL(value: string): CheckBuilderFinal; /** * Validate the extracted value is greater than or equal to a given value * * @param value - the value or a function returning the value * @returns a new CheckBuilderFinal */ gte(value: X | ((session: Session) => X)): CheckBuilderFinal; /** * Validate the extracted value is greater than or equal to a given value, passed as a Gatling * Expression Language String * * @param value - the value, as a Gatling Expression Language String * @returns a new CheckBuilderFinal */ gteEL(value: string): CheckBuilderFinal; } export declare const wrapCheckBuilderValidate: <X>(_underlying: JvmCheckBuilderValidate<X>) => CheckBuilderValidate<X>;