### Question:
ConfigurableUnwiseCharsEncoder implements UnwiseCharsEncoder { @Override public String encode(String value) { String escaped = escaper.escape(value); if (!Objects.equals(escaped, value)) { logger.warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", value, escaped); } return escaped; } ConfigurableUnwiseCharsEncoder(String unwiseChars);  ConfigurableUnwiseCharsEncoder(StyxConfig config);  ConfigurableUnwiseCharsEncoder(StyxConfig config, Logger logger);  ConfigurableUnwiseCharsEncoder(String unwiseChars, Logger logger); @Override String encode(String value); static final String ENCODE_UNWISECHARS; }### Answer:
@Test public void loadsUnwiseCharsToEncodeFromConfigurations() { ConfigurableUnwiseCharsEncoder encoder = newUnwiseCharsEncoder("|,},{"); assertThat(encoder.encode("|}{"), is("%7C%7D%7B")); }
@Test public void shouldHandleEmptyUnwiseChars() { ConfigurableUnwiseCharsEncoder encoder = newUnwiseCharsEncoder(""); assertThat(encoder.encode("|}{"), is("|}{")); }
@Test public void shouldEncodeUnwiseCharsMixedWithOtherChars() { ConfigurableUnwiseCharsEncoder encoder = newUnwiseCharsEncoder("|,{,}"); String urlWithUnwiseChars = "/search.do?foo={&srsReport=Landing|AutoS|HOTEL|Hotel%20Il%20Duca%20D%27Este" + "|0|0|0|2|1|2|284128&srsr=Landing|AutoS|HOTEL|Hotel%20Il%20Duca%20D%27Este|0|0|0|2|1|2|284128"; assertThat(encoder.encode(urlWithUnwiseChars), is("/search.do?foo=%7B&srsReport=Landing%7CAutoS%7CHOTEL%7CHotel" + "%20Il%20Duca%20D%27Este%7C0%7C0%7C0%7C2%7C1%7C2%7C284128&srsr=Landing%7CAutoS%7CHOTEL%7CHotel%20Il%20" + "Duca%20D%27Este%7C0%7C0%7C0%7C2%7C1%7C2%7C284128")); }
@Test public void shouldLogErrorMessageInCaseOfEncodingUnwiseChars() throws Exception { Logger logger = mock(Logger.class); ConfigurableUnwiseCharsEncoder encoder = new ConfigurableUnwiseCharsEncoder(newStyxConfig("|"), logger); assertThat(encoder.encode("|}{"), is("%7C}{")); verify(logger).warn("Value contains unwise chars. you should fix this. raw={}, escaped={}: ", "|}{", "%7C}{"); }
@Test public void shouldNotLogIfNotEncoding() throws Exception { Logger logger = mock(Logger.class); ConfigurableUnwiseCharsEncoder encoder = new ConfigurableUnwiseCharsEncoder(newStyxConfig(""), logger); assertThat(encoder.encode("|}{"), is("|}{")); verifyZeroInteractions(logger); }