public static Optional<String> urlEncode(String raw) {
    try {
      return Optional.of(URLEncoder.encode(raw, UTF_8.toString()));
    } catch (UnsupportedEncodingException e) {
      return Optional.empty();
    }
  }
@Test
  public void urlEncode_whenNotEncoded_returnsEncoded() {
    assertThat(urlEncode(" ")).hasValue("+");
    assertThat(urlEncode("()[]{}<>")).hasValue("%28%29%5B%5D%7B%7D%3C%3E");
    assertThat(urlEncode("?!@#$%^&=+,;:'\"`/\\|~"))
        .hasValue("%3F%21%40%23%24%25%5E%26%3D%2B%2C%3B%3A%27%22%60%2F%5C%7C%7E");
  }