Class InternalMatcher
java.lang.Object
net.javacrumbs.jsonunit.core.internal.matchers.InternalMatcher
Internal class, please do not use outside the library
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInternalMatcher(@Nullable Object actual, Path path, String description, Configuration configuration) InternalMatcher(@Nullable Object actual, Path path, String description, Configuration configuration, String nodeDescription) -
Method Summary
Modifier and TypeMethodDescriptionassertType(Node.NodeType type) describedAs(String description) Sets the description of this object.voidfailOnType(Node node, String expectedType) voidisAbsent()Fails if the node exists.isArray()Fails if the selected JSON is not an Array or is not present.voidvoidisNotEqualTo(@Nullable Object expected) Fails if compared documents are equal.voidvoidisNull()voidisObject()Fails if the selected JSON is not an Object or is not present.voidFails if the node is missing.voidvoidisString()Fails if the selected JSON is not a String or is not present.voidisStringEqualTo(@Nullable String expected) Fails if the selected JSON is not a String or is not present or the value is not equal to expected value.voidmatches(org.hamcrest.Matcher<?> matcher) Matches the node using Hamcrest matcher.Creates an assert object that only compares given node.when(ConfigurationWhen.PathsParam object, ConfigurationWhen.ApplicableForPath... actions) Sets advanced/local options.whenIgnoringPaths(String... pathsToBeIgnored) withDifferenceListener(DifferenceListener differenceListener) withIgnorePlaceholder(String ignorePlaceholder) Sets the placeholder that can be used to ignore values.withMatcher(String matcherName, org.hamcrest.Matcher<?> matcher) Adds a internalMatcher to be used in ${json-unit.matches:matcherName} macro.withOptions(Option firstOption, Option... otherOptions) Sets options changing comparison behavior.withTolerance(double tolerance) Sets the tolerance for floating number comparison.withTolerance(@Nullable BigDecimal tolerance) Sets the tolerance for floating number comparison.
-
Field Details
-
ACTUAL
- See Also:
-
-
Constructor Details
-
InternalMatcher
public InternalMatcher(@Nullable Object actual, Path path, String description, Configuration configuration, String nodeDescription) -
InternalMatcher
public InternalMatcher(@Nullable Object actual, Path path, String description, Configuration configuration)
-
-
Method Details
-
whenIgnoringPaths
-
describedAs
Sets the description of this object. -
withIgnorePlaceholder
Sets the placeholder that can be used to ignore values. The default value is ${json-unit.ignore} -
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. -
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. -
withMatcher
Adds a internalMatcher to be used in ${json-unit.matches:matcherName} macro. -
withDifferenceListener
-
withOptions
Sets options changing comparison behavior. This method has to be called before assertion. For more info seeOption- See Also:
-
when
public InternalMatcher when(ConfigurationWhen.PathsParam object, ConfigurationWhen.ApplicableForPath... actions) Sets advanced/local options. This method has to be called before assertion. For more info seeConfiguration.when(PathsParam, ApplicableForPath...)- See Also:
-
isEqualTo
-
isStringEqualTo
Fails if the selected JSON is not a String or is not present or the value is not equal to expected value. -
isNotEqualTo
Fails if compared documents are equal. The expected object is converted to JSON before comparison. Ignores order of sibling nodes and whitespaces. -
node
Creates an assert object that only compares given node. The path is denoted by JSON path, for example.assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1"); -
isAbsent
public void isAbsent()Fails if the node exists. -
isPresent
public void isPresent()Fails if the node is missing. -
isPresent
-
isArray
Fails if the selected JSON is not an Array or is not present. -
assertType
-
assertIntegralNumber
-
isObject
public void isObject()Fails if the selected JSON is not an Object or is not present. -
isString
public void isString()Fails if the selected JSON is not a String or is not present. -
isNull
public void isNull() -
isNotNull
public void isNotNull() -
getActualNode
-
failOnType
-
matches
public void matches(org.hamcrest.Matcher<?> matcher) Matches the node using Hamcrest matcher.- Numbers are mapped to BigDecimal
- Arrays are mapped to a Collection
- Objects are mapped to a map so you can use json(Part)Equals or a Map matcher
-