### Question:
UriUtils { public static String uriSegmentPercentDecode(final String src) { return uriPathPercentDecode(src, false); } private  UriUtils(); static String uriSegmentPercentDecode(final String src); @SuppressWarnings({"squid:S3776", "checkstyle:magicnumber"}) static String uriPathPercentDecode(final String src, final boolean allowSeparator);  }### Answer:
@Test public void shouldAcceptSafeChars() { String safeChars = "!$&'()*+,;=:@-._~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; assertEquals(safeChars, uriSegmentPercentDecode(safeChars)); }
@Test public void shouldAcceptEmpty() { assertEquals("", uriSegmentPercentDecode("")); }
@Test(expected = IllegalArgumentException.class) public void shouldRejectInvalidChars() { uriSegmentPercentDecode("this/is/not a valid segment"); }
@Test(expected = IllegalArgumentException.class) public void shouldRejectInvalidEncoding() { uriSegmentPercentDecode("%XY"); }
@Test(expected = IllegalArgumentException.class) public void shouldRejectIncompleteEncoding() { uriSegmentPercentDecode("Test%"); }
@Test public void shouldPercentDecode() { StringBuilder b = new StringBuilder(); for (int i = 0; i < Character.MAX_CODE_POINT; i++) { if (i < 256 || Character.isAlphabetic(i) || Character.isDigit(i)) { b.appendCodePoint(i); } } final String expected = b.toString(); final String escaped = UrlEscapers.urlPathSegmentEscaper().escape(expected); assertEquals(expected, uriSegmentPercentDecode(escaped)); }