### Question:
SensitiveDataRemovingPatternLayoutEncoder extends PatternLayoutEncoder { protected String removeSensitiveData(String txt) { return txt.replaceAll("(?i)(username|apikey|password)(=|:|%3D)([^&\\s]{2,})", "$1$2<$1>") .replaceAll("(\"name\" ?: ?\"apiKey\",(\\s*\"label\": ?\".*\",)?\\s*\"value\" ?: \")([^\"\\s*]*)", "$1<apikey>") .replaceAll("(\"name\" ?: ?\"baseUrl\",(\\s*\"label\": ?\".*\",)?\\s*\"value\" ?: \")([^\"\\s*]*)", "$1<url>") ; }  Charset getCharset(); void setCharset(Charset charset); byte[] encode(ILoggingEvent event);  }### Answer:
@Test public void shouldRemoveSensitiveData() { SensitiveDataRemovingPatternLayoutEncoder encoder = new SensitiveDataRemovingPatternLayoutEncoder(); String result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: result = encoder.removeSensitiveData("http: assertThat(result).isEqualTo("http: result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: result = encoder.removeSensitiveData("https: assertThat(result).isEqualTo("https: final String darrApiKeyField = " \"name\": \"apiKey\",\n" + " \"label\": \"API Key\",\n" + " \"value\": \"12345678\","; result = encoder.removeSensitiveData(darrApiKeyField); assertThat(result).isEqualTo(darrApiKeyField.replace("12345678", "<apikey>")); final String darrUrlField = " \"name\": \"baseUrl\",\n" + " \"label\": \"URL\",\n" + " \"value\": \"http: result = encoder.removeSensitiveData(darrUrlField); assertThat(result).isEqualTo(darrUrlField.replace("http: final String darrUrlField2 = "\"name\" : \"baseUrl\",\n" + " \"value\" : \"http: result = encoder.removeSensitiveData(darrUrlField2); assertThat(result).isEqualTo(darrUrlField2.replace("http: final String darrUrlField3 = "\"name\" : \"baseUrl\",\n" + " \"value\" : \"http: result = encoder.removeSensitiveData(darrUrlField3); assertThat(result).isEqualTo(darrUrlField3.replace("http: }