### Question:
URITemplate { public String encodeLiteralCharacters(boolean isQuery) { final float encodedRatio = 1.5f; StringBuilder sb = new StringBuilder((int)(encodedRatio * template.length())); for (UriChunk chunk : uriChunks) { String val = chunk.getValue(); if (chunk instanceof Literal) { sb.append(HttpUtils.encodePartiallyEncoded(val, isQuery)); } else { sb.append(val); } } return sb.toString(); } URITemplate(String theTemplate); String getLiteralChars(); String getValue(); String getPatternValue(); List<String> getVariables(); List<String> getCustomVariables(); boolean match(String uri, MultivaluedMap<String, String> templateVariableToValue); String substitute(List<String> values); String substitute(Map<String, ? extends Object> valuesMap,
                             Set<String> encodePathSlashVars,
                             boolean allowUnresolved); String encodeLiteralCharacters(boolean isQuery); static URITemplate createTemplate(Path path); static URITemplate createTemplate(String pathValue); static URITemplate createExactTemplate(String pathValue); static int compareTemplates(URITemplate t1, URITemplate t2); static final String TEMPLATE_PARAMETERS; static final String LIMITED_REGEX_SUFFIX; static final String FINAL_MATCH_GROUP; }### Answer:
@Test public void testEncodeLiteralCharacters() { URITemplate ut = new URITemplate("a {id} b"); assertEquals("a%20{id}%20b", ut.encodeLiteralCharacters(false)); }
@Test public void testEncodeLiteralCharactersNotVariable() { URITemplate ut = new URITemplate("a {digit:[0-9]} b"); assertEquals("a%20{digit:[0-9]}%20b", ut.encodeLiteralCharacters(false)); }