### Question:
StringUtils { public static String subString(String s, int startIndex, int endIndex, int minLength) { if (s.length() <= minLength) { return s; } if (s.length() <= startIndex) { return ""; } if (s.length() <= endIndex || endIndex == -1) { return s.substring(startIndex); } return s.substring(startIndex, endIndex); } private  StringUtils(); static String stripTrailingSlash(String stringWithPossibleTrailingSlash); static String subString(String s, int startIndex, int endIndex, int minLength); static String capitaliseFirstWord(String s); static String capitaliseAllWords(String s);  }### Answer:
@Test public void testSubString() { assertEquals("Normal String should return substring", "abc", StringUtils.subString("abcdefghijklmnop", 0, 3, 10)); assertEquals("String shorter than minlength should return whole string", "abcdefghijklmnop", StringUtils.subString("abcdefghijklmnop", 0, 3, 30)); assertEquals("String shorter than startIndex should return empty string", "", StringUtils.subString("abcdefghijklmnopqrstuvwxyz", 29, 31, 10)); assertEquals("String shorter than endIndex should return whole string", "abcdefghijklmnopqrstuvwxyz", StringUtils.subString("abcdefghijklmnopqrstuvwxyz", 0, 39, 20)); assertEquals("String endIndex of -1 should return whole string", "abcdefghijklmnopqrstuvwxyz", StringUtils.subString("abcdefghijklmnopqrstuvwxyz", 0, -1, 20)); }