### Question:
StringNormaliser { public static String normalise(String text) { return text.trim().replaceAll("\\p{Pd}", "-").replaceAll("\\r", " ").replaceAll("\\n", " ").replaceAll("\\s+", " ") .replaceAll("[^\\x20-\\x7e]", ""); } private  StringNormaliser(); static String normalise(String text);  }### Answer:
@Test public void shouldReplaceNewlineWithASingleSpace() { String text = "New\n\nlines\rare replaced"; String normalisedText = StringNormaliser.normalise(text); Assert.assertEquals("New lines are replaced", normalisedText); }
@Test public void shouldReplaceCarriageReturnWithASingleSpace() { String text = "Carriage\r\rreturns\rare replaced"; String normalisedText = StringNormaliser.normalise(text); Assert.assertEquals("Carriage returns are replaced", normalisedText); }
@Test public void shouldReplaceMultipleWhitespaceWithASingleSpace() { String text = " White\t \t spaces\t are replaced "; String normalisedText = StringNormaliser.normalise(text); Assert.assertEquals("White spaces are replaced", normalisedText); }