### Question:
CouchURIHelper { String encodeId(String in) { try { String encodedString = HierarchicalUriComponents.encodeUriComponent(in, "UTF-8", HierarchicalUriComponents.Type.PATH_SEGMENT); if (encodedString.startsWith(CouchConstants._design_prefix_encoded) || encodedString.startsWith(CouchConstants._local_prefix_encoded)) { return encodedString.replaceFirst("%2F", "/"); } else { return encodedString; } } catch (UnsupportedEncodingException uee) { throw new RuntimeException( "Couldn't encode ID " + in, uee); } } CouchURIHelper(URI rootUri); URI getRootUri(); URI changesUri(Map<String, Object> query); URI bulkDocsUri(); URI revsDiffUri(); URI documentUri(String documentId); URI documentUri(String documentId, Map<String, Object> query); URI attachmentUri(String documentId, String attachmentId); URI attachmentUri(String documentId, Map<String, Object> query, String attachmentId);  }### Answer:
@Test public void encodePathComponent_slashShouldBeEncoded() throws Exception { String in = "/path1/path2"; Assert.assertEquals("%2Fpath1%2Fpath2", helper(path+"/test").encodeId(in)); }
@Test public void encodeQueryParameter_noLeadingQuestionMark() throws Exception { String in = "a"; Assert.assertTrue(helper(path+"/test").encodeId(in).charAt(0) != '?'); }