Class Configuration

java.lang.Object
net.javacrumbs.jsonunit.core.Configuration

public class Configuration extends Object
Comparison configuration. Immutable.
  • Constructor Details

  • Method Details

    • empty

      @NotNull public static @NotNull Configuration empty()
      Returns an empty configuration.
    • withTolerance

      @NotNull public @NotNull Configuration withTolerance(@Nullable @Nullable BigDecimal tolerance)
      Sets numerical comparison tolerance.
      Parameters:
      tolerance -
      Returns:
    • withTolerance

      @NotNull public @NotNull Configuration withTolerance(double tolerance)
      Sets numerical comparison tolerance.
      Parameters:
      tolerance -
      Returns:
    • when

      @NotNull public @NotNull Configuration when(@NotNull @NotNull Option first, @NotNull @NotNull Option... next)
      Adds comparison options.
      Parameters:
      first -
      next -
      Returns:
    • withOptions

      @NotNull public @NotNull Configuration withOptions(@NotNull @NotNull Option first, @NotNull @NotNull Option... next)
      Adds comparison options.
      Parameters:
      first -
      next -
      Returns:
    • withOptions

      @NotNull public @NotNull Configuration withOptions(@NotNull @NotNull Options options)
      Sets comparison options.
      Parameters:
      options -
      Returns:
    • when

      @NotNull public final @NotNull Configuration when(@NotNull @NotNull ConfigurationWhen.PathsParam object, @NotNull @NotNull ConfigurationWhen.ApplicableForPath... actions)
      Defines general comparison options. See ConfigurationWhen.path(java.lang.String) for some examples.
      Parameters:
      object - an object to apply actions, e.g. ConfigurationWhen.path(java.lang.String), ConfigurationWhen.rootPath().
      actions - actions to be applied on the object.
      See Also:
    • withPathOptions

      @NotNull public @NotNull Configuration withPathOptions(@NotNull @NotNull List<PathOption> pathOptions)
    • whenIgnoringPaths

      @NotNull public @NotNull Configuration whenIgnoringPaths(@NotNull @NotNull Collection<String> pathsToBeIgnored)
    • whenIgnoringPaths

      @NotNull public @NotNull Configuration whenIgnoringPaths(@NotNull @NotNull 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
      Parameters:
      pathsToBeIgnored -
      Returns:
      See Also:
    • withIgnorePlaceholder

      @NotNull public @NotNull Configuration withIgnorePlaceholder(@NotNull @NotNull String ignorePlaceholder)
      Sets ignore placeholder.
      Parameters:
      ignorePlaceholder -
      Returns:
    • withMatcher

      @NotNull public @NotNull Configuration withMatcher(@NotNull @NotNull String matcherName, @NotNull @NotNull org.hamcrest.Matcher<?> matcher)
      Adds a matcher to be used in ${json-unit.matches:matcherName} macro.
      Parameters:
      matcherName -
      matcher -
      Returns:
    • withDifferenceListener

      @NotNull public @NotNull Configuration withDifferenceListener(@NotNull @NotNull DifferenceListener differenceListener)
      Sets difference listener
    • dummyDifferenceListener

      @NotNull public static @NotNull DifferenceListener dummyDifferenceListener()
    • getMatcher

      @Nullable public @Nullable org.hamcrest.Matcher<?> getMatcher(String matcherName)
    • getTolerance

      @Nullable public @Nullable BigDecimal getTolerance()
    • getOptions

      @NotNull public @NotNull Options getOptions()
    • getIgnorePlaceholder

      @NotNull public @NotNull String getIgnorePlaceholder()
    • getPathOptions

      @NotNull public @NotNull List<PathOption> getPathOptions()
    • getPathsToBeIgnored

      @NotNull public @NotNull Set<String> getPathsToBeIgnored()
    • getDifferenceListener

      @NotNull public @NotNull DifferenceListener getDifferenceListener()
    • shouldIgnore

      public boolean shouldIgnore(String expectedValue)