### Question:
StringUtil { public static String replace(final String str, final String oldStr, final String newStr) { Assertion.check().isNotNull(str); final StringBuilder result = new StringBuilder(str); replace(result, oldStr, newStr); return result.toString(); } private  StringUtil(); static boolean isBlank(final String strValue); static String first2LowerCase(final String strValue); static String first2UpperCase(final String strValue); static String constToLowerCamelCase(final String str); static String constToUpperCamelCase(final String str); static String camelToConstCase(final String str); static String camelToSnakeCase(final String str); static boolean isUpperCamelCase(final String testString); static boolean isLowerCamelCase(final String testString); static boolean isSimpleLetterOrDigit(final char c); static String replace(final String str, final String oldStr, final String newStr); static void replace(final StringBuilder str, final String oldStr, final String newStr); static String format(final String msg, final Object... params);  }### Answer:
@Test public void testStringReplace() { assertEquals("azertyuiop", StringUtil.replace("azertYYuiop", "YY", "y")); assertEquals("yazertyuiopy", StringUtil.replace("YYazertYYuiopYY", "YY", "y")); assertEquals("yyyaYay", StringUtil.replace("YYYYYYaYaYY", "YY", "y")); assertEquals("YY", StringUtil.replace("YYY", "YY", "Y")); assertEquals("azertyuiop", StringUtil.replace("azertyuiop", "ZZ", "Y")); }
@Test public void testStringReplaceWithNull() { Assertions.assertThrows(NullPointerException.class, () -> StringUtil.replace((String) null, "YY", "Y")); }
@Test public void testStringReplaceWithNullOldString() { Assertions.assertThrows(NullPointerException.class, () -> StringUtil.replace("azertYYuiop", null, "Y")); }
@Test public void testStringReplaceWithEmptyOldString() { Assertions.assertThrows(IllegalStateException.class, () -> StringUtil.replace("azertYYuiop", "", "Y")); }
@Test public void testStringReplaceWithNullNewString() { Assertions.assertThrows(NullPointerException.class, () -> StringUtil.replace("azertYYuiop", "YY", null)); }