Class DslJsonAssertion

    • Constructor Detail

      • DslJsonAssertion

        public DslJsonAssertion​(String name,
                                String query)
    • Method Detail

      • matches

        public DslJsonAssertion matches​(String regex)
        Specifies to check the value extracted with the given query to match the given regular expression.
        Parameters:
        regex - specifies the regular expression to check extracted value with.
        Returns:
        the assertion element for further configuration or usage.
      • equalsTo

        public DslJsonAssertion equalsTo​(Object value)
        Specifies to check the value extracted is the given value.

        Warning: This method serializes the value with Jackson library and then configures JMeter element with such value. If you want to pass the raw JSON to compare with, use equalsToJson(String) instead.

        If you want to use a JMeter expression (Eg: "${VAR}") for checking for some primitive type (like int or boolean), then use equalsToJson(String) instead.

        Parameters:
        value - specifies the value to check the extracted value against. Here you can pass primitive types (like ints, booleans, etc), Strings, collections (lists, maps), arrays, and even objects to be serialized with Jackson library. You can also specify null if you want to check if extracted value is null.
        Returns:
        the assertion element for further configuration or usage.
        See Also:
        equalsToJson(String)
      • equalsToJson

        public DslJsonAssertion equalsToJson​(String json)
        Specifies the raw JSON value to check the extracted value is equals to.

        When using this method you must provide the actual JSON representation of the value. For example, if you want to check the value is a given string, then you have to quote it like "\"test string\"".

        In general prefer using equalsTo(Object) which is simpler.

        Parameters:
        json - specifies the raw json to check the extracted value against. You can specify here simple values like "1", "\"test string\"", or more complex ones like "[1, 2, 3]" or "{\"prop\": 1}". If you want to use a JMeter expression (eg: "${VAR}") for checking for a string value, you should add quotes to it (eg: "\"${VAR}\"").
        Returns:
        the assertion element for further configuration or usage.
        Since:
        1.16
        See Also:
        equalsTo(Object)
      • not

        public DslJsonAssertion not()
        Allows to check the inverse/negated condition specified by the rest of assertion settings.

        For example, you can use it to check that a given path doesn't exist, or that extracted value is not a given one or does not match a given pattern.

        Returns:
        the assertion element for further configuration or usage.
      • not

        public DslJsonAssertion not​(boolean negated)
        Sames as not but allowing to enable/disable the setting with a variable.
        Parameters:
        negated - when true, specifies to negate the check. When false, specifies to not negate the check.
        Returns:
        the assertion element for further configuration or usage.