### Question:
DefaultJsonObject implements JsonObject { @Override @Nullable public JsonObject getJsonObject(String name) { if (contains(name)) { JSONObject newJsonObject; try { newJsonObject = getJsonObject().getJSONObject(name); } catch (JSONException e) { throw new JsonParsingException(e.getMessage()); } return Optional.ofNullable(newJsonObject) .map(Object::toString) .map(DefaultJsonObject::new) .orElse(null); } return null; } DefaultJsonObject(String jsonString); @Override boolean contains(String key); @Override boolean isEmpty(); @Override List<T> getAsList(String name, Class<T> type); @Override List<String> getAsStringList(String name); @Override @Nullable String getAsString(String name); @Override @Nullable Instant getAsInstant(String name); @Nullable @Override Long getAsLong(String name); @Override @Nullable JsonObject getJsonObject(String name); @Override List<JsonObject> getJsonObjects(String name); @Override Map<String, String> getKeyValueMap(); @Override String asJsonString(); @Override String toString();  }### Answer:
@Test public void getJsonObject_propertyDoesNotExists_returnsNull() { JsonObject jsonObject = cut.getJsonObject("keyDoesNotExist"); assertThat(jsonObject).isNull(); }
@Test public void getJsonObject_propertyExistsButIsNotAnObject_throwsException() { assertThatThrownBy(() -> cut.getJsonObject(KEY_1)).isInstanceOf(JsonParsingException.class); }