TSDBEntity implements Serializable { public static String replaceUnsupportedChars(String input) { if(input != null){ return input.replaceAll("[^a-zA-Z0-9\\./\\-_]+", UNSUPPORTED_CHARACTER_REPLACEMENT); } else return input; } protected  TSDBEntity(); protected  TSDBEntity(String scope, String metric); String getScope(); String getMetric(); String getUid(); Map<String, String> getTags(); void removeTag(String tagName); void setTags(Map<String, String> tags); static void validateTags(Map<String, String> tags); static String replaceUnsupportedChars(String input); void setTag(String key, String value); String getTag(String key); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testReplaceUnsupportedChars() { String expected = "mytag1"; String actual = TSDBEntity.replaceUnsupportedChars("mytag1"); assertEquals(expected, actual); expected = "ANCESTOR_DOMAINS__ANCESTORS"; actual = TSDBEntity.replaceUnsupportedChars("ANCESTOR_DOMAINS|ANCESTORS"); assertEquals(expected, actual); expected = "OU__0"; actual = TSDBEntity.replaceUnsupportedChars("OU=0"); assertEquals(expected, actual); expected = "url__ actual = TSDBEntity.replaceUnsupportedChars("url: assertEquals(expected, actual); expected = "ANCESTOR_DOMAINS__ANCESTORS"; actual = TSDBEntity.replaceUnsupportedChars("ANCESTOR_DOMAINS__ANCESTORS"); assertEquals(expected, actual); expected = "ANCESTOR_DOMAINS____ANCESTORS"; actual = TSDBEntity.replaceUnsupportedChars("ANCESTOR_DOMAINS__|ANCESTORS"); assertEquals(expected, actual); expected = ""; actual = TSDBEntity.replaceUnsupportedChars(""); assertEquals(expected, actual); expected = null; actual = TSDBEntity.replaceUnsupportedChars(null); assertEquals(expected, actual); }