Paragraph { public String toHtml() { return String.format("<p>%s</p>", this.text != null ? this.text : ""); } Paragraph();  Paragraph(String text); boolean hasText(); String getText(); void setText(String text); @Override String toString(); String toHtml();  }
@Test public void testToHtml() { assertEquals("<p>foo</p>",new Paragraph("foo").toHtml()); assertEquals("<p></p>",new Paragraph().toHtml()); }