@Test public void should_replace_underscore_character() throws Exception { JsonNode fromInputStream = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(UNDERSCORE_JSON)); List<String> whiteList = new ArrayList<>(Arrays.asList("tenant","sp","v", "storage")); ReplacePatternUtils replacePatternUtils = new ReplacePatternUtils(whiteList); String bodyWithoutUnderscore = replacePatternUtils.replaceUnderscoreBySharp(JsonHandler.unprettyPrint(fromInputStream)); assertThat(bodyWithoutUnderscore).contains("#tenant").contains("#v").contains("#storage.#nbc"); assertThat(bodyWithoutUnderscore).contains("_tenantx").contains("test._tenant"); }
public String replaceUnderscoreBySharp(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, underscorePattern, SHARP_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("_nbc", "#nbc"); }
ReplacePatternUtils { public String replaceUnderscoreBySharp(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, underscorePattern, SHARP_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("_nbc", "#nbc"); } }
ReplacePatternUtils { public String replaceUnderscoreBySharp(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, underscorePattern, SHARP_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("_nbc", "#nbc"); } ReplacePatternUtils(List<String> whiteList); }
ReplacePatternUtils { public String replaceUnderscoreBySharp(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, underscorePattern, SHARP_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("_nbc", "#nbc"); } ReplacePatternUtils(List<String> whiteList); String replaceUnderscoreBySharp(String textToReplace); String replaceSharpByUnderscore(String textToReplace); }
ReplacePatternUtils { public String replaceUnderscoreBySharp(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, underscorePattern, SHARP_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("_nbc", "#nbc"); } ReplacePatternUtils(List<String> whiteList); String replaceUnderscoreBySharp(String textToReplace); String replaceSharpByUnderscore(String textToReplace);  }