Class JsonAssert.ConfigurableJsonAssert

  • All Implemented Interfaces:
    org.assertj.core.api.Assert<JsonAssert,​Object>, org.assertj.core.api.Descriptable<JsonAssert>, org.assertj.core.api.ExtensionPoints<JsonAssert,​Object>
    Enclosing class:
    JsonAssert

    public static class JsonAssert.ConfigurableJsonAssert
    extends JsonAssert
    JsonAssert that can be configured to prevent mistakes like assertThatJson(...).isEqualsTo(...).when(...);
    • Method Detail

      • when

        public JsonAssert.ConfigurableJsonAssert when​(net.javacrumbs.jsonunit.core.Option first,
                                                      net.javacrumbs.jsonunit.core.Option... other)
        Adds comparison options.
      • when

        public final JsonAssert.ConfigurableJsonAssert when​(net.javacrumbs.jsonunit.core.ConfigurationWhen.PathsParam object,
                                                            net.javacrumbs.jsonunit.core.ConfigurationWhen.ApplicableForPath... actions)
        Adds path specific options.
        See Also:
        Configuration.when(PathsParam, ApplicableForPath...)
      • withOptions

        public JsonAssert.ConfigurableJsonAssert withOptions​(net.javacrumbs.jsonunit.core.internal.Options options)
        Sets comparison options.
        Parameters:
        options -
        Returns:
      • withConfiguration

        public JsonAssert.ConfigurableJsonAssert withConfiguration​(Function<net.javacrumbs.jsonunit.core.Configuration,​net.javacrumbs.jsonunit.core.Configuration> configurationFunction)
        Allows to configure like this assertThatJson(...) .withConfiguration(c -> c.withMatcher("positive", greaterThan(valueOf(0))) ....
      • whenIgnoringPaths

        public JsonAssert.ConfigurableJsonAssert 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
        Parameters:
        pathsToBeIgnored -
        Returns:
      • withMatcher

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

        public JsonAssert.ConfigurableJsonAssert withDifferenceListener​(net.javacrumbs.jsonunit.core.listener.DifferenceListener differenceListener)
        Sets difference listener
      • describedAs

        public JsonAssert.ConfigurableJsonAssert describedAs​(org.assertj.core.description.Description description)
        Specified by:
        describedAs in interface org.assertj.core.api.Descriptable<JsonAssert>
        Overrides:
        describedAs in class org.assertj.core.api.AbstractAssert<JsonAssert,​Object>