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.
  • 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:
      node in class JsonFluentAssert
      Parameters:
      newPath -
      Returns:
      object comparing only node given by path.
    • whenIgnoringPaths

      public JsonFluentAssert.ConfigurableJsonFluentAssert whenIgnoringPaths(String... pathsToBeIgnored)
      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

      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

      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 see Option
      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 see Configuration.when(PathsParam, ApplicableForPath...)
      See Also:
      • Configuration.when(ConfigurationWhen.PathsParam, ApplicableForPath...)