### Question:
Document implements Map<String, Object>, Bson { @Override public String toString() { return toString(false); } Document();  Document(String key, Object value);  Document(Map<String, ?> map); void cloneInto(Document targetDocument); Document cloneDeeply(); Document append(String key, Object value); Document appendAll(Map<String, Object> map); @Override boolean containsValue(Object value); @Override Object get(Object key); Object getOrMissing(Object key); @Override void clear(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override Object put(String key, Object value); void putIfNotNull(String key, Object value); @Override void putAll(Map<? extends String, ?> m); @Override Object remove(Object key); @Override @SuppressWarnings("unchecked") Document clone(); @Override Set<String> keySet(); @Override Collection<Object> values(); @Override Set<Entry<String, Object>> entrySet(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); String toString(boolean compactKey); String toString(boolean compactKey, String prefix, String suffix);  }### Answer:
@Test void testToString() throws Exception { assertThat(new Document()).hasToString("{}"); assertThat(new Document("key", "value")).hasToString("{\"key\" : \"value\"}"); assertThat(new Document("key", new Document("value", 12345L))).hasToString("{\"key\" : {\"value\" : 12345}}"); assertThat(json("array: [{'123a': {name: 'old'}}]")).hasToString("{\"array\" : [ { \"123a\" : { \"name\" : \"old\" } } ]}"); }
@Test void testToString_compactKey() throws Exception { assertThat(new Document().toString(true)) .isEqualTo("{}"); assertThat(new Document("key", "value").toString(true)) .isEqualTo("{key: \"value\"}"); assertThat(new Document("key", new Document("value", 12345L)).toString(true)) .isEqualTo("{key: {value: 12345}}"); assertThat(json("array: [{'123a': {name: 'old'}}]").toString(true)) .isEqualTo("{array: [ { 123a: { name: \"old\" } } ]}"); }