### Question:
HtmlDocumentBuilder { public String build(String body) { StringBuilder result = new StringBuilder(); result.append("<!DOCTYPE html>\n"); result.append("<html>\n"); result.append("<head>\n"); if (!Strings.isNullOrEmpty(title)) { result.append("<title>").append(title.trim()).append("</title>\n"); } for (String stylesheet : stylesheets) { result.append("<link rel=\"stylesheet\" type=\"text/css\" href=\""); result.append(stylesheet); result.append("\">\n"); } for (String headerInjection : headerInjections) { result.append(headerInjection); result.append("\n"); } result.append("</head>\n"); result.append("<body>\n"); if (!Strings.isNullOrEmpty(body)) { result.append(body).append("\n"); } result.append("</body>\n"); result.append("</html>\n"); return result.toString(); }  HtmlDocumentBuilder addStylesheet(String url); HtmlDocumentBuilder withTitle(String title); HtmlDocumentBuilder addHeaderInjection(String element); String build(String body);  }### Answer:
@Test public void shouldCreateHtml5Doctype() { String result = new HtmlDocumentBuilder().build(null); assertThat(result, startsWith("<!DOCTYPE html>")); }
@Test public void shouldCreateHeadElement() { String result = new HtmlDocumentBuilder().build(null); assertThat(result, containsString("<head>")); assertThat(result, containsString("</head>")); }
@Test public void shouldCreateBody() { String result = new HtmlDocumentBuilder().build(null); assertThat(result, containsString("<body>")); assertThat(result, containsString("</body>")); }
@Test public void shouldAddNoTitleByDefault() { String result = new HtmlDocumentBuilder().build(null); assertThat(result, not(containsString("<title>"))); assertThat(result, not(containsString("</title>"))); }
@Test public void shouldAddNoStylesheetByDefault() { String result = new HtmlDocumentBuilder().build(null); assertThat(result, not(containsString("<link"))); }
@Test public void shouldAddNoHeaderInjectionByDefault() { String result = new HtmlDocumentBuilder().build(null); Assert.assertEquals("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "</head>\n" + "<body>\n" + "</body>\n" + "</html>\n", result); }
@Test public void shouldAddBody() { String result = new HtmlDocumentBuilder().build("content"); assertThat(result, containsString("<body>\ncontent\n</body>")); }