### Question:
DefaultJsonObject implements JsonObject { @Override @Nullable public String getAsString(String name) { if (contains(name)) { try { return getJsonObject().getString(name); } catch (JSONException e) { throw new JsonParsingException(e.getMessage()); } } 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 getAsString_keyExists_returnsStringValue() { assertThat(cut.getAsString(KEY_1)).isEqualTo(STRING_TEXT); }
@Test public void getAsString_keyDoesNotExists_returnsNull() { assertThat(cut.getAsString("keyDoesNotExist")).isNull(); }
@Test public void getAsString_keyDoesExistButTypeIsWrong_throwsException() { cut = createJsonParser(KEY_2, STRING_LIST_VALUE); assertThatThrownBy(() -> cut.getAsString(KEY_2)).isInstanceOf(JsonParsingException.class); }