### Question:
ObjectEmbedding extends StructuredEmbedding { @Override public String toHtml() { Object object = getData(); if (object == null) { return ""; } return StringEscapeUtils.escapeXml10(JSONValue.toJSONString(object, JSONStyle.NO_COMPRESS)); } ObjectEmbedding(String kind, String name, Object object, EmbeddingPriority priority); @Override String toHtml();  }### Answer:
@Test public void toHtml_ShouldReturnEmpty_WhenDataIsNull() { final Object nullData = null; final ObjectEmbedding cut = new ObjectEmbedding(null, null, nullData, null); final String html = cut.toHtml(); assertThat(html).isEmpty(); }
@Test public void toHtml_ShouldEncodeDataAsJsonAndEscapeHtmlCharacters_WhenDataIsPresent() { final SomeClass data = new SomeClass(); data.child = new SomeClass(); data.child.text = "sub-text"; data.text = "Escaping<test> &amp; \"checked'"; data.number = 42; final ObjectEmbedding cut = new ObjectEmbedding(null, null, data, null); final String html = cut.toHtml(); assertThat(html).isEqualTo("" + "{&quot;number&quot;:42," + "&quot;text&quot;:&quot;Escaping&lt;test&gt; &amp;amp; \\&quot;checked&apos;&quot;," + "&quot;child&quot;:{&quot;number&quot;:0,&quot;text&quot;:&quot;sub-text&quot;,&quot;child&quot;:null}}"); }