ValueMatcher implements JsonSerializable, Predicate<JsonSerializable> { protected ValueMatcher() { } protected  ValueMatcher(); @NonNull static ValueMatcher newNumberRangeMatcher(@Nullable Double min, @Nullable Double max); @NonNull static ValueMatcher newValueMatcher(@NonNull JsonValue value); @NonNull static ValueMatcher newIsPresentMatcher(); @NonNull static ValueMatcher newIsAbsentMatcher(); @NonNull static ValueMatcher newVersionMatcher(@NonNull String constraint); @NonNull static ValueMatcher newArrayContainsMatcher(@NonNull JsonPredicate predicate, int index); @NonNull static ValueMatcher newArrayContainsMatcher(@NonNull JsonPredicate predicate); @NonNull static ValueMatcher parse(@Nullable JsonValue jsonValue); @Override boolean apply(@Nullable JsonSerializable jsonSerializable); @NonNull @Override String toString();  }
@Test public void testValueMatcher() throws JsonException { JsonValue value = JsonValue.wrap(5); ValueMatcher matcher = ValueMatcher.newValueMatcher(value); assertTrue(matcher.apply(value)); assertTrue(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); value = JsonValue.wrap(6); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertFalse(matcher.apply(value, true)); value = JsonValue.wrap(true); matcher = ValueMatcher.newValueMatcher(value); assertTrue(matcher.apply(value)); assertTrue(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); value = JsonValue.wrap(false); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertFalse(matcher.apply(value, true)); value = JsonValue.wrap("test"); matcher = ValueMatcher.newValueMatcher(value); assertTrue(matcher.apply(value)); assertTrue(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); value = JsonValue.wrap("TEST"); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); value = JsonValue.wrap("wrong"); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertFalse(matcher.apply(value, true)); value = JsonValue.wrap(5.0); matcher = ValueMatcher.newValueMatcher(value); assertTrue(matcher.apply(value)); assertTrue(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); value = JsonValue.wrap(6.0); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertFalse(matcher.apply(value, true)); value = JsonValue.wrap(new Object[] { "first-value", "second-value", null }); assertNotNull(value); matcher = ValueMatcher.newValueMatcher(value); assertNotNull(matcher); assertTrue(matcher.apply(value)); assertTrue(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); value = JsonValue.wrap(new Object[] { "FIRST-Value", "Second-Value", null }); assertNotNull(value); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); Map<String, Object> map = new HashMap<>(); map.put("null-key", null); map.put("some-key", "some-value"); map.put("another-key", "another-value"); value = JsonValue.wrap(map); assertNotNull(value); matcher = ValueMatcher.newValueMatcher(value); assertNotNull(matcher); assertTrue(matcher.apply(value)); assertTrue(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); map = new HashMap<>(); map.put("null-key", null); map.put("some-key", "Some-Value"); map.put("another-key", "ANOTHER-VALUE"); value = JsonValue.wrap(map); assertNotNull(value); assertFalse(matcher.apply(value)); assertFalse(matcher.apply(value, false)); assertTrue(matcher.apply(value, true)); }