StringUtils { public static String getStringOrDefault(String inputString, String def) { String stringOrEmpty = getStringOrEmpty(inputString); if (isEmpty(stringOrEmpty)) { return def; } else { return stringOrEmpty; } } private  StringUtils(); static boolean isEmpty(CharSequence cs); static boolean isNotEmpty(CharSequence cs); static boolean isNotEmptyTrimmed(String str); static String trim(String str); static String getStringOrEmpty(String inputString); static String getStringOrDefault(String inputString, String def); static String replaceWildcardConfigs(String contentWithWildcards, Map<String, Object> properties);  }
@Test public void testGetStringOrDefault(TestContext context){ context.assertEquals(def, StringUtils.getStringOrDefault(null, def)); context.assertEquals(def, StringUtils.getStringOrDefault(empty, def)); context.assertEquals(def, StringUtils.getStringOrDefault(" ", def)); context.assertEquals(text, StringUtils.getStringOrDefault(text, def)); context.assertEquals(text, StringUtils.getStringOrDefault(" " + text + " ", def)); }