ImmutableJsonObjectBuilder implements JsonObjectBuilder { @Override public ImmutableJsonObjectBuilder set(final CharSequence key, final int value, final Predicate<JsonField> predicate) { return set(key, JsonFactory.newValue(value), predicate); } private  ImmutableJsonObjectBuilder(); static ImmutableJsonObjectBuilder newInstance(); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final int value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final long value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final double value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final boolean value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, @Nullable final String value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final CharSequence key, final JsonValue value,
            final Predicate<JsonField> predicate); @Override JsonObjectBuilder set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value,
            final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder set(final JsonField field, final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder remove(final CharSequence key); @Override ImmutableJsonObjectBuilder remove(final JsonFieldDefinition fieldDefinition); @Override ImmutableJsonObjectBuilder setAll(final Iterable<JsonField> fields, final Predicate<JsonField> predicate); @Override ImmutableJsonObjectBuilder setAll(final Iterable<JsonField> fields); @Override ImmutableJsonObjectBuilder removeAll(); @Override Iterator<JsonField> iterator(); @Override boolean isEmpty(); @Override int getSize(); @Override Stream<JsonField> stream(); @Override JsonObject build(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void tryToSetValueWithEmptyKey() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> underTest.set("", eddard.getValue())) .withMessage("The key or pointer must not be empty!") .withNoCause(); }
@Test public void tryToSetValueWithNullJsonPointer() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> underTest.set((CharSequence) null, cersei.getValue(), Objects::nonNull)) .withMessage("The %s must not be null!", "key or pointer char sequence") .withNoCause(); }
@Test public void tryToSetValueWithSlashString() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> underTest.set("/", eddard.getValue())) .withMessage("The key or pointer must not be empty!") .withNoCause(); }
@Test public void setValueWithSlashAsJsonKey() { final JsonKey key = JsonFactory.newKey("/"); final JsonField expected = JsonFactory.newField(key, cersei.getValue()); underTest.set(key, expected.getValue()); assertThat(underTest).containsOnly(expected); }
@Test public void doSetFieldIfPredicateEvaluatesToTrue() { final JsonField bazField = JsonFactory.newField(bazKey, eddard.getValue()); final JsonField barField = JsonFactory.newField(barKey, JsonFactory.newObject().set(bazField)); final JsonField expectedField = JsonFactory.newField(fooKey, JsonFactory.newObject().set(barField)); underTest.set(pointer, eddard.getValue(), jsonValue -> true); assertThat(underTest).containsExactly(expectedField); }