SearchUtil { public static String replaceWildcards(final String input) { if (input == null) { return null; } else { return input.replace(ESCAPE, ESCAPE + ESCAPE) .replace(WILDCARD_ALL_REPLACEMENT, ESCAPE + WILDCARD_ALL_REPLACEMENT) .replace(WILDCARD_SINGLE_REPLACEMENT, ESCAPE + WILDCARD_SINGLE_REPLACEMENT) .replace(WILDCARD_ALL, WILDCARD_ALL_REPLACEMENT) .replace(WILDCARD_SINGLE, WILDCARD_SINGLE_REPLACEMENT); } } private  SearchUtil(); static String replaceWildcards(final String input);  }
@Test void normalInput() { final String input = "normal input without wildcards"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo(input); }
@Test public void escapePercentageCharacters() { final String input = "TST%-111%"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo("TST\\%-111\\%"); }
@Test public void escapeUnderscoreCharacter() { final String input = "TST-1_1"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo("TST-1\\_1"); }
@Test void escapeBothWildcards() { final String input = "input with_ %wildcards"; final String expected = "input with\\_ \\%wildcards"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo(expected); }
@Test public void convertAsteriskToPercentage() { final String input = "TST-11*"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo("TST-11%"); }
@Test public void convertQuestionMarksToUnderscores() { final String input = "TS???-111"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo("TS___-111"); }
@Test public void convertNull() { final String input = null; assertThat(SearchUtil.replaceWildcards(input)).isNull(); }
@Test public void escapeBackslashes() { final String input = "TS\\T-1\\11"; assertThat(SearchUtil.replaceWildcards(input)).isEqualTo("TS\\\\T-1\\\\11"); }