public ConfigurableJsonFluentAssert withDifferenceListener(DifferenceListener differenceListener) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withDifferenceListener(differenceListener)); }
/** * Creates an assert object that only compares given node. * The path is denoted by JSON path, for example. Second call navigates from the root. * * <code> * assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1"); * </code> * * @param newPath * @return object comparing only node given by path. */ public ConfigurableJsonFluentAssert node(String newPath) { return new ConfigurableJsonFluentAssert(actual, path.copy(newPath), description, configuration); }
public ConfigurableJsonFluentAssert withDifferenceListener(DifferenceListener differenceListener) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withDifferenceListener(differenceListener)); }
/** * Creates an assert object that only compares given node. * The path is denoted by JSON path, for example. Second call navigates from the root. * * <code> * assertThatJson("{\"root\":{\"test\":[1,2,3]}}").node("root.test[0]").isEqualTo("1"); * </code> * * @param newPath * @return object comparing only node given by path. */ public ConfigurableJsonFluentAssert node(String newPath) { return new ConfigurableJsonFluentAssert(actual, path.copy(newPath), description, configuration); }
/** * Sets options changing comparison behavior. This method has to be called * <b>before</b> assertion. * For more info see {@link net.javacrumbs.jsonunit.core.Option} * * @param firstOption * @param otherOptions * @see net.javacrumbs.jsonunit.core.Option */ public ConfigurableJsonFluentAssert when(Option firstOption, Option... otherOptions) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withOptions(firstOption, otherOptions)); } }
/** * Sets options changing comparison behavior. This method has to be called * <b>before</b> assertion. * For more info see {@link net.javacrumbs.jsonunit.core.Option} * * @param firstOption * @param otherOptions * @see net.javacrumbs.jsonunit.core.Option */ public ConfigurableJsonFluentAssert when(Option firstOption, Option... otherOptions) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withOptions(firstOption, otherOptions)); } }
/** * Sets the description of this object. * * @param description * @return */ public ConfigurableJsonFluentAssert describedAs(String description) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration); }
/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. */ public ConfigurableJsonFluentAssert withMatcher(String matcherName, Matcher<?> matcher) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withMatcher(matcherName, matcher)); }
/** * 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. * * @param tolerance */ public ConfigurableJsonFluentAssert withTolerance(BigDecimal tolerance) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withTolerance(tolerance)); }
/** * Adds paths to be ignored */ public ConfigurableJsonFluentAssert whenIgnoringPaths(String... pathsToBeIgnored) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.whenIgnoringPaths(pathsToBeIgnored)); }
/** * 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. * * @param tolerance */ public ConfigurableJsonFluentAssert withTolerance(BigDecimal tolerance) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withTolerance(tolerance)); }
/** * Creates a new instance of <code>{@link JsonFluentAssert}</code>. * It is not called assertThat to not clash with StringAssert. * The json parameter is converted to JSON using ObjectMapper. * * @param json * @return new JsonFluentAssert object. */ public static ConfigurableJsonFluentAssert assertThatJson(Object json) { return new ConfigurableJsonFluentAssert(convertToJson(json, ACTUAL), getPathPrefix(json)); }
/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. */ public ConfigurableJsonFluentAssert withMatcher(String matcherName, Matcher<?> matcher) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withMatcher(matcherName, matcher)); }
/** * Sets the description of this object. * * @param description * @return */ public ConfigurableJsonFluentAssert describedAs(String description) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration); }
/** * Sets the placeholder that can be used to ignore values. * The default value is ${json-unit.ignore} * * @param ignorePlaceholder * @return */ public ConfigurableJsonFluentAssert ignoring(String ignorePlaceholder) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withIgnorePlaceholder(ignorePlaceholder)); }
/** * Adds paths to be ignored */ public ConfigurableJsonFluentAssert whenIgnoringPaths(String... pathsToBeIgnored) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.whenIgnoringPaths(pathsToBeIgnored)); }
/** * Creates a new instance of <code>{@link JsonFluentAssert}</code>. * It is not called assertThat to not clash with StringAssert. * The json parameter is converted to JSON using ObjectMapper. * * @param json * @return new JsonFluentAssert object. */ public static ConfigurableJsonFluentAssert assertThatJson(Object json) { return new ConfigurableJsonFluentAssert(convertToJson(json, ACTUAL), getPathPrefix(json)); }
/** * Sets the placeholder that can be used to ignore values. * The default value is ${json-unit.ignore} * * @param ignorePlaceholder * @return */ public ConfigurableJsonFluentAssert ignoring(String ignorePlaceholder) { return new ConfigurableJsonFluentAssert(actual, path, description, configuration.withIgnorePlaceholder(ignorePlaceholder)); }