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
All Methods Instance Methods Concrete Methods 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.Option firstOption, net.javacrumbs.jsonunit.core.Option... otherOptions)Sets options changing comparison behavior.JsonFluentAssert.ConfigurableJsonFluentAssertwhenIgnoringPaths(String... pathsToBeIgnored)Adds paths to be ignoredJsonFluentAssert.ConfigurableJsonFluentAssertwithDifferenceListener(net.javacrumbs.jsonunit.core.listener.DifferenceListener differenceListener)JsonFluentAssert.ConfigurableJsonFluentAssertwithMatcher(String matcherName, org.hamcrest.Matcher<?> matcher)Adds a matcher 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 Detail
-
node
public JsonFluentAssert.ConfigurableJsonFluentAssert node(String newPath)
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
public JsonFluentAssert.ConfigurableJsonFluentAssert whenIgnoringPaths(String... pathsToBeIgnored)
Adds paths to be ignored
-
as
public JsonFluentAssert.ConfigurableJsonFluentAssert as(String description)
Sets the description of this object.- Parameters:
description-- Returns:
-
describedAs
public JsonFluentAssert.ConfigurableJsonFluentAssert describedAs(String description)
Sets the description of this object.- Parameters:
description-- Returns:
-
ignoring
public JsonFluentAssert.ConfigurableJsonFluentAssert ignoring(String ignorePlaceholder)
Sets the placeholder that can be used to ignore values. The default value is ${json-unit.ignore}- Parameters:
ignorePlaceholder-- Returns:
-
withTolerance
public JsonFluentAssert.ConfigurableJsonFluentAssert withTolerance(double tolerance)
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
public JsonFluentAssert.ConfigurableJsonFluentAssert withTolerance(BigDecimal tolerance)
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 matcher 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
-
-