@Test public void should_replace_sharp_character() throws Exception { JsonNode fromInputStream = JsonHandler.getFromInputStream(PropertiesUtils.getResourceAsStream(SHARP_JSON)); List<String> whiteList = new ArrayList<>(Arrays.asList("tenant","sp","v", "storage")); ReplacePatternUtils replacePatternUtils = new ReplacePatternUtils(whiteList); String bodyWithoutSharp = replacePatternUtils.replaceSharpByUnderscore(JsonHandler.unprettyPrint(fromInputStream)); assertThat(bodyWithoutSharp).contains("_tenant").contains("_v").contains("_storage._nbc"); assertThat(bodyWithoutSharp).contains("#tenantx").contains("test.#tenant"); }
public String replaceSharpByUnderscore(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, sharpPattern, UNDERSCORE_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("#nbc", "_nbc"); }
ReplacePatternUtils { public String replaceSharpByUnderscore(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, sharpPattern, UNDERSCORE_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("#nbc", "_nbc"); } }
ReplacePatternUtils { public String replaceSharpByUnderscore(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, sharpPattern, UNDERSCORE_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("#nbc", "_nbc"); } ReplacePatternUtils(List<String> whiteList); }
ReplacePatternUtils { public String replaceSharpByUnderscore(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, sharpPattern, UNDERSCORE_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 replaceSharpByUnderscore(String textToReplace) { LOGGER.debug("textToReplace" + textToReplace); String replacedString = replaceStringWithPattern(textToReplace, sharpPattern, UNDERSCORE_REPLACEMENT); LOGGER.debug("replacedString" + replacedString); return replacedString.replaceAll("#nbc", "_nbc"); } ReplacePatternUtils(List<String> whiteList); String replaceUnderscoreBySharp(String textToReplace); String replaceSharpByUnderscore(String textToReplace);  }