@Override public int getSize() { return wrapped.getSize(); }
@Override public int getSize() { return wrapped.getSize(); }
@Override public int getSize() { return wrapped.getSize(); }
@Override public int getSize() { return wrapped.getSize(); }
/** * Verifies that the actual JSON object has the expected size. * * @param expectedSize the expected size. * @return this assert to allow method chaining. */ public JsonObjectAssert hasSize(final int expectedSize) { isNotNull(); final int actualSize = actual.getSize(); Assertions.assertThat(actualSize) .overridingErrorMessage("Expected JSON object to have size <%d> but was <%d>", expectedSize, actualSize) .isEqualTo(expectedSize); return this; }
/** * Creates a new {@link StatusDetailMessage} from a JSON object. * * @param jsonObject the JSON object. * @return the message. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws JsonMissingFieldException if the passed in {@code jsonObject} was not in the expected format. */ public static StatusDetailMessage fromJson(final JsonObject jsonObject) { if (jsonObject.getSize() != 1) { throw new JsonParseException("Message must contain exactly one field, but does not:\n" + jsonObject); } final JsonField messageField = jsonObject.iterator().next(); final Level level = Level.valueOf(messageField.getKeyName()); final JsonValue message = messageField.getValue(); return of(level, message); }
/** * Creates a new {@link StatusDetailMessage} from a JSON object. * * @param jsonObject the JSON object. * @return the message. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws JsonMissingFieldException if the passed in {@code jsonObject} was not in the expected format. */ public static StatusDetailMessage fromJson(final JsonObject jsonObject) { if (jsonObject.getSize() != 1) { throw new JsonParseException("Message must contain exactly one field, but does not:\n" + jsonObject); } final JsonField messageField = jsonObject.iterator().next(); final Level level = Level.valueOf(messageField.getKeyName()); final JsonValue message = messageField.getValue(); return of(level, message); }
/** * Maps the specified JsonObject to a {@link com.mongodb.BasicDBObject} which can be stored in MongoDB. * * @param jsonObject the object to be mapped. * @return {@code jsonObject} as BasicDBObject. * @throws NullPointerException if {@code jsonObject} is {@code null}. */ private BasicDBObject mapJsonObjectToBasicDBObject(final JsonObject jsonObject) { checkNotNull(jsonObject, "JSON object to be mapped"); final BasicDBObject result = new BasicDBObject(jsonObject.getSize()); jsonObject.forEach(jsonField -> result.put(reviseKeyName(jsonField.getKey()), mapJsonValueToJavaObject(jsonField.getValue()))); return result; }