UriEncoderDecoder { public URI encode(String uri) { return encode(uri, UriEncoderDecoder::encodeSegment); }  URI encode(String uri); URI encode(String uri, Function<String, String> encode); String decodeAndDropAuthority(URI uri); String decodeAndDropAuthority(URI uri, Function<String, String> decode); String withoutAuthority(URI uri); String withoutAuthority(URI uri, Function<String, String> decode);  }
@Test void encodeRelative() { assertThat(UriEncoderDecoder.encode("уровень1/уровень 2=/&файл пробел+плюс")) .hasToString("%D1%83%D1%80%D0%BE%D0%B2%D0%B5%D0%BD%D1%8C1/%D1%83%D1%80%D0%BE%D0%B2%D0%B5%D0%BD%D1" + "%8C%202%3D/%26%D1%84%D0%B0%D0%B9%D0%BB%20%D0%BF%D1%80%D0%BE%D0%B1%D0%B5%D0%BB%2B" + "%D0%BF%D0%BB%D1%8E%D1%81"); }
@Test void encodeWithAbsolute() { assertThat(UriEncoderDecoder.encode("https: .hasToString("https: "%D0%B2%D0%B5%D0%BD%D1%8C%202%3D/%3F%26%D1%84%D0%B0%D0%B9%D0%BB%20%D0%BF%D1%80%D0%BE%D0%B1%D0" + "%B5%D0%BB%2B%D0%BF%D0%BB%D1%8E%D1%81"); }
@Test void encodeWithAuthority() { assertThat( UriEncoderDecoder.encode("https: ).hasToString("https: "%D0%BE%D0%B2%D0%B5%D0%BD%D1%8C%202%3D/%3F%26%D1%84%D0%B0%D0%B9%D0%BB%20%D0%BF%D1%80%D0%BE%D0%B1%D0" + "%B5%D0%BB%2B%D0%BF%D0%BB%D1%8E%D1%81"); }