Source:
public void testSanitizeForSaving() { String subjectWithWhitespaces = " subject to be sanitized by removing leading/trailing whitespace "; Text contentWithWhitespaces = new Text(" content to be sanitized by removing leading/trailing whitespace "); ______TS("valid sanitation of admin email"); AdminEmailAttributes adminEmailAttributes = AdminEmailAttributes .builder(subjectWithWhitespaces, addressReceiverListString, groupReceiverListFileKey, contentWithWhitespaces, date) .build(); ______TS("success: sanitized whitespace"); adminEmailAttributes.sanitizeForSaving(); assertEquals("subject to be sanitized by removing leading/trailing whitespace", adminEmailAttributes.getSubject()); assertEquals("content to be sanitized by removing leading/trailing whitespace", adminEmailAttributes.getContentValue()); ______TS("success: sanitized code block"); adminEmailAttributes.content = new Text("<code>System.out.println(\"Hello World\");</code>"); adminEmailAttributes.sanitizeForSaving(); assertEquals("<code>System.out.println(&#34;Hello World&#34;);</code>", adminEmailAttributes.getContentValue()); ______TS("success: sanitized superscript"); adminEmailAttributes.content = new Text("f(x) = x<sup>2</sup>"); adminEmailAttributes.sanitizeForSaving(); assertEquals("f(x) &#61; x<sup>2</sup>", adminEmailAttributes.getContentValue()); ______TS("success: sanitized chemical formula"); adminEmailAttributes.content = new Text("<p>Chemical formula: C<sub>6</sub>H<sub>12</sub>O<sub>6</sub></p>"); adminEmailAttributes.sanitizeForSaving(); assertEquals("<p>Chemical formula: C<sub>6</sub>H<sub>12</sub>O<sub>6</sub></p>", adminEmailAttributes.getContentValue()); ______TS("success: sanitized invalid closing tag"); adminEmailAttributes.content = new Text("</td></option></div> invalid closing tags"); adminEmailAttributes.sanitizeForSaving(); assertEquals(" invalid closing tags", adminEmailAttributes.getContentValue()); }

Target:
public void testSanitizeForSaving() { String subjectWithWhitespaces = " subject to be sanitized by removing leading/trailing whitespace "; Text contentWithWhitespaces = new Text(" content to be sanitized by removing leading/trailing whitespace "); ______TS("valid sanitation of admin email"); AdminEmailAttributes adminEmailAttributes = AdminEmailAttributes .builder(subjectWithWhitespaces, addressReceiverListString, groupReceiverListFileKey, contentWithWhitespaces) .withSendDate(date) .build(); ______TS("success: sanitized whitespace"); adminEmailAttributes.sanitizeForSaving(); assertEquals("subject to be sanitized by removing leading/trailing whitespace", adminEmailAttributes.getSubject()); assertEquals("content to be sanitized by removing leading/trailing whitespace", adminEmailAttributes.getContentValue()); ______TS("success: sanitized code block"); adminEmailAttributes.content = new Text("<code>System.out.println(\"Hello World\");</code>"); adminEmailAttributes.sanitizeForSaving(); assertEquals("<code>System.out.println(&#34;Hello World&#34;);</code>", adminEmailAttributes.getContentValue()); ______TS("success: sanitized superscript"); adminEmailAttributes.content = new Text("f(x) = x<sup>2</sup>"); adminEmailAttributes.sanitizeForSaving(); assertEquals("f(x) &#61; x<sup>2</sup>", adminEmailAttributes.getContentValue()); ______TS("success: sanitized chemical formula"); adminEmailAttributes.content = new Text("<p>Chemical formula: C<sub>6</sub>H<sub>12</sub>O<sub>6</sub></p>"); adminEmailAttributes.sanitizeForSaving(); assertEquals("<p>Chemical formula: C<sub>6</sub>H<sub>12</sub>O<sub>6</sub></p>", adminEmailAttributes.getContentValue()); ______TS("success: sanitized invalid closing tag"); adminEmailAttributes.content = new Text("</td></option></div> invalid closing tags"); adminEmailAttributes.sanitizeForSaving(); assertEquals(" invalid closing tags", adminEmailAttributes.getContentValue()); }