### Question:
StringTransforms { public static String trim(String input, final String toTrim) { if (input == null) return null; Preconditions.checkNotNull(toTrim); input = input.trim(); while (!input.isEmpty() && input.length() >= toTrim.length() && input.startsWith(toTrim)) input = input.substring(toTrim.length(), input.length()); while (!input.isEmpty() && input.length() >= toTrim.length() && input.endsWith(toTrim)) input = input.substring(0, input.length() - toTrim.length()); return input; }  static String trim(String input, final String toTrim); static String trim(final String input, final char toTrim);  }### Answer:
@Test public void shouldTrimWhiteSpaceAndPattern() { final String input = " 111hello11 "; final String trimmed = StringTransforms.trim(input, "1"); Assert.assertEquals("hello", trimmed); }
@Test public void shouldTrimWhiteSpace() { final String input = " 111hello11 "; final String trimmed = StringTransforms.trim(input, "2"); Assert.assertEquals("111hello11", trimmed); }
@Test public void shouldHandleBlankString() { final String input = ""; final String trimmed = StringTransforms.trim(input, ""); Assert.assertTrue(trimmed.isEmpty()); }
@Test public void shouldTrimSingleSlash() { final String input = "/hello/there/test.file"; final String trimmed = StringTransforms.trim(input, "/"); Assert.assertEquals("hello/there/test.file", trimmed); }