Package net.javacrumbs.jsonunit.fluent
Class JsonFluentAssert.ConfigurableJsonFluentAssert
java.lang.Object
net.javacrumbs.jsonunit.fluent.JsonFluentAssert
net.javacrumbs.jsonunit.fluent.JsonFluentAssert.ConfigurableJsonFluentAssert
- Enclosing class:
- JsonFluentAssert
public static class JsonFluentAssert.ConfigurableJsonFluentAssert extends JsonFluentAssert
JsonFluentAssert that can be configured. To make sure that configuration is done before comparison and not after.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.javacrumbs.jsonunit.fluent.JsonFluentAssert
JsonFluentAssert.ArrayAssert, JsonFluentAssert.ConfigurableJsonFluentAssert -
Method Summary
Modifier and Type Method Description JsonFluentAssert.ConfigurableJsonFluentAssertas(String description)Sets the description of this object.JsonFluentAssert.ConfigurableJsonFluentAssertdescribedAs(String description)Sets the description of this object.JsonFluentAssert.ConfigurableJsonFluentAssertignoring(String ignorePlaceholder)Sets the placeholder that can be used to ignore values.JsonFluentAssert.ConfigurableJsonFluentAssertnode(String newPath)Creates an assert object that only compares given node.JsonFluentAssert.ConfigurableJsonFluentAssertwhen(net.javacrumbs.jsonunit.core.ConfigurationWhen.PathsParam object, net.javacrumbs.jsonunit.core.ConfigurationWhen.ApplicableForPath... actions)Sets advanced/local options.JsonFluentAssert.ConfigurableJsonFluentAssertwhen(net.javacrumbs.jsonunit.core.Option firstOption, net.javacrumbs.jsonunit.core.Option... otherOptions)Sets options changing comparison behavior.JsonFluentAssert.ConfigurableJsonFluentAssertwhenIgnoringPaths(String... pathsToBeIgnored)Makes JsonUnit ignore the specified paths in the actual value.JsonFluentAssert.ConfigurableJsonFluentAssertwithDifferenceListener(net.javacrumbs.jsonunit.core.listener.DifferenceListener differenceListener)JsonFluentAssert.ConfigurableJsonFluentAssertwithMatcher(String matcherName, org.hamcrest.Matcher<?> matcher)Adds a internalMatcher to be used in ${json-unit.matches:matcherName} macro.JsonFluentAssert.ConfigurableJsonFluentAssertwithTolerance(double tolerance)Sets the tolerance for floating number comparison.JsonFluentAssert.ConfigurableJsonFluentAssertwithTolerance(BigDecimal tolerance)Sets the tolerance for floating number comparison.Methods inherited from class net.javacrumbs.jsonunit.fluent.JsonFluentAssert
assertThatJson, hasSameStructureAs, isAbsent, isArray, isEqualTo, isNotEqualTo, isObject, isPresent, isString, isStringEqualTo, matches
-
Method Details
-
node
Creates an assert object that only compares given node. The path is denoted by JSON path, for example. Second call navigates from the root.assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1");- Overrides:
nodein classJsonFluentAssert- Parameters:
newPath-- Returns:
- object comparing only node given by path.
-
whenIgnoringPaths
Makes JsonUnit ignore the specified paths in the actual value. If the path matches, it's completely ignored. It may be missing, null or have any value -
as
Sets the description of this object.- Parameters:
description-- Returns:
-
describedAs
Sets the description of this object.- Parameters:
description-- Returns:
-
ignoring
Sets the placeholder that can be used to ignore values. The default value is ${json-unit.ignore}- Parameters:
ignorePlaceholder-- Returns:
-
withTolerance
Sets the tolerance for floating number comparison. If set to null, requires exact match of the values. For example, if set to 0.01, ignores all differences lower than 0.01, so 1 and 0.9999 are considered equal.- Parameters:
tolerance-
-
withTolerance
Sets the tolerance for floating number comparison. If set to null, requires exact match of the values. For example, if set to 0.01, ignores all differences lower than 0.01, so 1 and 0.9999 are considered equal.- Parameters:
tolerance-
-
withMatcher
public JsonFluentAssert.ConfigurableJsonFluentAssert withMatcher(String matcherName, org.hamcrest.Matcher<?> matcher)Adds a internalMatcher to be used in ${json-unit.matches:matcherName} macro. -
withDifferenceListener
public JsonFluentAssert.ConfigurableJsonFluentAssert withDifferenceListener(net.javacrumbs.jsonunit.core.listener.DifferenceListener differenceListener) -
when
public JsonFluentAssert.ConfigurableJsonFluentAssert when(net.javacrumbs.jsonunit.core.Option firstOption, net.javacrumbs.jsonunit.core.Option... otherOptions)Sets options changing comparison behavior. This method has to be called before assertion. For more info seeOption- Parameters:
firstOption-otherOptions-- See Also:
Option
-
when
public final JsonFluentAssert.ConfigurableJsonFluentAssert when(net.javacrumbs.jsonunit.core.ConfigurationWhen.PathsParam object, net.javacrumbs.jsonunit.core.ConfigurationWhen.ApplicableForPath... actions)Sets advanced/local options. This method has to be called before assertion. For more information seeConfiguration.when(PathsParam, ApplicableForPath...)- See Also:
Configuration.when(ConfigurationWhen.PathsParam, ApplicableForPath...)
-