/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. */ public ConfigurableJsonMatcher<T> withMatcher(String matcherName, Matcher<?> matcher) { configuration = configuration.withMatcher(matcherName, matcher); return this; }
/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. */ public ConfigurableJsonMatcher<T> withMatcher(String matcherName, Matcher<?> matcher) { configuration = configuration.withMatcher(matcherName, matcher); return this; }
/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. * * @param matcherName * @param matcher * @return */ public ConfigurableJsonAssert withMatcher(String matcherName, Matcher<?> matcher) { return withConfiguration(c -> c.withMatcher(matcherName, matcher)); }
/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. */ public static Configuration withMatcher(String matcherName, Matcher<?> matcher) { return Configuration.empty().withMatcher(matcherName, matcher); }
/** * Adds a matcher to be used in ${json-unit.matches:matcherName} macro. */ public static Configuration withMatcher(String matcherName, Matcher<?> matcher) { return Configuration.empty().withMatcher(matcherName, matcher); }
/** * 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)); }
/** * 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)); }
@Test void shouldUseMultipleMatchers() { Matcher<?> divisionMatcher = new DivisionMatcher(); Matcher<?> emptyMatcher = empty(); assertJsonEquals( "{test: '${json-unit.matches:isDivisibleBy}3', x: '${json-unit.matches:isEmpty}'}", "{\"test\":6, \"x\": []}", JsonAssert .withMatcher("isDivisibleBy", divisionMatcher) .withMatcher("isEmpty", emptyMatcher) ); }