### Question:
StringUtils { public static String removeLastOccurrence(String input, String subStr) { if (input == null) { return null; } input = input.trim(); if (input.isEmpty()) { return ""; } if (input.endsWith(subStr)) { input = input.substring(0, input.length() - 1); } return input; }  static String removeFirstAndLastOccurrence(String input, String str); static String prependSubstring(String uri, String subStr); static String prependSubstring(String uri, String subStr, boolean checkAlreadyPrepended); static String prependSubstring(String uri, String subStr, boolean checkAlreadyPrepended, boolean shouldTrimWhitespaceFirst); static String removeLastOccurrence(String input, String subStr); static String resolveExpressions(String expression, Map<String, String> properties);  }### Answer:
@Test public void removeLastOccurrenceTest() { assertNull(StringUtils.removeLastOccurrence(null, "any-string")); String whiteSpace = " "; assertEquals("", StringUtils.removeLastOccurrence(whiteSpace, "any-string")); String hasSlashes = " /blah/ "; assertEquals("/blah", StringUtils.removeLastOccurrence(hasSlashes, "/")); }