### Question:
Rewriters { public static StringOperator replace(@NotNull final String what, @NotNull final String with) { return new StringOperator() { @Override public String apply(final String arg) { return Strings.replace(arg, what, with); } }; }  static StringOperator replace(@NotNull final String what, @NotNull final String with); static StringOperator replace(@NotNull final Map<String,String> map);  }### Answer:
@Test public void replace_1_basic() { assertThat(Rewriters.replace("YYY","TTT").apply("XXX YYY ZZZ")).isEqualTo("XXX TTT ZZZ"); }
@Test public void replace_1_same() { String str = "ABCDE"; assertThat(Rewriters.replace("YYY","TTT").apply(str)).isSameAs(str); }
@Test public void replace_map_1() { assertThat(Rewriters.replace(Collections.singletonMap("YYY", "TTT")).apply("XXX YYY ZZZ")) .isEqualTo("XXX TTT ZZZ"); }
@Test public void replace_map_2x2() { Map<String,String> map = new HashMap<String, String>(); map.put("AAA", "X"); map.put("BBB", "YYYYY"); String original = "AAAAAABBBBBB"; String expected = "XXYYYYYYYYYY"; assertThat(Rewriters.replace(map).apply(original)).isEqualTo(expected); }
@Test public void replace_map_same() { String original = "1234567890"; assertThat(Rewriters.replace(Collections.singletonMap("YYY", "TTT")).apply(original)) .isSameAs(original); }