public class DslJsonAssertion extends BaseTestElement implements DslAssertion
By default, the assertion will just check for the existence of given JSON JMESPath.
| Modifier and Type | Class and Description |
|---|---|
static class |
DslJsonAssertion.CodeBuilder |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isRegex |
protected boolean |
not |
protected String |
query |
protected DslJsonExtractor.JsonQueryLanguage |
queryLanguage |
protected boolean |
validateValue |
protected String |
value |
guiClass, name| Constructor and Description |
|---|
DslJsonAssertion(String name,
String query) |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.jmeter.testelement.TestElement |
buildTestElement() |
DslJsonAssertion |
equalsTo(Object value)
Specifies to check the value extracted is the given value.
|
DslJsonAssertion |
equalsToJson(String json)
Specifies the raw JSON value to check the extracted value is equals to.
|
DslJsonAssertion |
matches(String regex)
Specifies to check the value extracted with the given query to match the given regular
expression.
|
DslJsonAssertion |
not()
Allows to check the inverse/negated condition specified by the rest of assertion settings.
|
DslJsonAssertion |
not(boolean negated)
Sames as
not but allowing to enable/disable the setting with a variable. |
DslJsonAssertion |
queryLanguage(DslJsonExtractor.JsonQueryLanguage queryLanguage)
Allows selecting the query language to use for JSON assertion.
|
buildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildTreeUnder, showInGuiprotected String query
protected boolean isRegex
protected boolean validateValue
protected String value
protected boolean not
protected DslJsonExtractor.JsonQueryLanguage queryLanguage
public DslJsonAssertion matches(String regex)
regex - specifies the regular expression to check extracted value with.public DslJsonAssertion equalsTo(Object 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.
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.equalsToJson(String)public DslJsonAssertion equalsToJson(String json)
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.
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}\"").equalsTo(Object)public DslJsonAssertion not()
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.
public DslJsonAssertion not(boolean negated)
not but allowing to enable/disable the setting with a variable.negated - when true, specifies to negate the check. When false, specifies to not negate
the check.public DslJsonAssertion queryLanguage(DslJsonExtractor.JsonQueryLanguage queryLanguage)
queryLanguage - specifies the query language to use for assertions. When no value is
specified, JMESPath is used by default.DslJsonExtractor.JsonQueryLanguageprotected org.apache.jmeter.testelement.TestElement buildTestElement()
buildTestElement in class BaseTestElementCopyright © 2024. All rights reserved.