### Question:
StringTools { public static String getFirstSentence(String text, int maxLength) { final int indexOfPoint = text.indexOf('.'); if ((indexOfPoint > 0) && ((indexOfPoint < maxLength) || (maxLength < 0))) { return text.substring(0, indexOfPoint + 1); } return maxLength < 0 ? text : text.substring(0, Math.min(text.length(), maxLength)); }  static String cleanControlChars(String inInput, boolean inRemoveTabAndLf, boolean inRemoveSurroundingQuotes); static String cr2br(String inInput); static String unescapeString(String myString); static String truncate(String inString, int inMaxSize); static String truncate(String inString, int inMaxSize, String inEndMarker); static String getFirstSentence(String text, int maxLength);  }### Answer:
@Test public void getFirstSentenceTest() { final int maxLength = 5; final String text1 = "abc. def. ghi."; final String text2 = "abcdefg. hi."; final String text3 = "abcdejdbfkdjbfdkjbdk"; final String text4 = "av"; Assert.assertEquals("abc.", StringTools.getFirstSentence(text1, maxLength)); Assert.assertEquals("abcde", StringTools.getFirstSentence(text2, maxLength)); Assert.assertEquals("abcde", StringTools.getFirstSentence(text3, maxLength)); Assert.assertEquals("av", StringTools.getFirstSentence(text4, maxLength)); Assert.assertEquals("abc.", StringTools.getFirstSentence(text1, -1)); Assert.assertEquals("abcdefg.", StringTools.getFirstSentence(text2, -1)); Assert.assertEquals("abcdejdbfkdjbfdkjbdk", StringTools.getFirstSentence(text3, -1)); Assert.assertEquals("av", StringTools.getFirstSentence(text4, -1)); }