### Question:
HtmlSanitizer { public static @CheckForNull String sanitize(@CheckForNull String text) { if (StringUtils.isEmpty(text)) { return text; } else { return text.replaceAll("<(?!\\/?" + ALLOWED_TAGS + ">)", "&lt;") .replaceAll("(?<!<\\/?" + ALLOWED_TAGS + ")>", "&gt;"); } } private  HtmlSanitizer(); static @CheckForNull String sanitize(@CheckForNull String text);  }### Answer:
@Test public void testSanitize() { assertThat(HtmlSanitizer.sanitize(null), is(nullValue())); assertThat(HtmlSanitizer.sanitize("<p>"), is("<p>")); assertThat(HtmlSanitizer.sanitize("</p>"), is("</p>")); assertThat(HtmlSanitizer.sanitize("<div>"), is("<div>")); assertThat(HtmlSanitizer.sanitize("</div>"), is("</div>")); assertThat(HtmlSanitizer.sanitize("<span>"), is("<span>")); assertThat(HtmlSanitizer.sanitize("</span>"), is("</span>")); assertThat(HtmlSanitizer.sanitize("<br>"), is("<br>")); assertThat(HtmlSanitizer.sanitize("</br>"), is("</br>")); assertThat(HtmlSanitizer.sanitize("<b>"), is("<b>")); assertThat(HtmlSanitizer.sanitize("</b>"), is("</b>")); assertThat(HtmlSanitizer.sanitize("<strong>"), is("<strong>")); assertThat(HtmlSanitizer.sanitize("</strong>"), is("</strong>")); assertThat(HtmlSanitizer.sanitize("<i>"), is("<i>")); assertThat(HtmlSanitizer.sanitize("</i>"), is("</i>")); assertThat(HtmlSanitizer.sanitize("<em>"), is("<em>")); assertThat(HtmlSanitizer.sanitize("</em>"), is("</em>")); assertThat(HtmlSanitizer.sanitize("<u>"), is("<u>")); assertThat(HtmlSanitizer.sanitize("</u>"), is("</u>")); assertThat(HtmlSanitizer.sanitize("<script>"), is("&lt;script&gt;")); assertThat(HtmlSanitizer.sanitize("</script>"), is("&lt;/script&gt;")); assertThat(HtmlSanitizer.sanitize("<style>"), is("&lt;style&gt;")); assertThat(HtmlSanitizer.sanitize("</style>"), is("&lt;/style&gt;")); assertThat(HtmlSanitizer.sanitize("<"), is("&lt;")); assertThat(HtmlSanitizer.sanitize(">"), is("&gt;")); assertThat(HtmlSanitizer.sanitize("div"), is("div")); assertThat(HtmlSanitizer.sanitize("<div"), is("&lt;div")); assertThat(HtmlSanitizer.sanitize("div>"), is("div&gt;")); }