### Question:
StringUtil { public static String trimToNull(String str) { if (str == null || str.isEmpty()) { return null; } str = str.trim(); if (str.isEmpty()) { return null; } return str; } private  StringUtil(); static boolean isEmpty(String val); static boolean isNotEmpty(String val); static boolean isBlank(final CharSequence cs); static boolean isNotBlank(final CharSequence cs); static boolean contains(String val, char charToSearchFor); static boolean equalsIgnoreCase(String str1, String str2); static String[] split(String str, String token, int max); static String replace(String str, String from, String to); static String trim(final String str); static String trimToNull(String str); static String join(Object[] values, String joinToken); static T parse(String val, Class<T> type); static String capitalize(final String str); static String uncapitalize(final String str); static boolean endsWithIgnoreCase(String str, String suffix); static String stripEnd(final String str, final String stripChars);  }### Answer:
@Test public void testTrimToNull() { Assert.assertNull(StringUtil.trimToNull(null)); Assert.assertNull(StringUtil.trimToNull(" ")); Assert.assertNull(StringUtil.trimToNull(" ")); Assert.assertNull(StringUtil.trimToNull(" \n ")); Assert.assertEquals("A", StringUtil.trimToNull(" A")); Assert.assertEquals("A", StringUtil.trimToNull("A ")); Assert.assertEquals("A", StringUtil.trimToNull(" A ")); Assert.assertEquals("A", StringUtil.trimToNull(" A \n ")); }