### Question:
HttpUtil { public static String buildQuery(Map<String,String> params) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); boolean first = true; for (Map.Entry<String,String> param : params.entrySet()) { if (!first) { sb.append("&"); } sb.append(URLEncoder.encode(param.getKey(), "UTF-8")). append("="). append(URLEncoder.encode(param.getValue(), "UTF-8")); first = false; } return sb.toString(); }  static Map<String,String> getParams(URI uri); static Map<String, String> getParamsFromQuery(String queryString); static String buildQuery(Map<String,String> params);  }### Answer:
@Test public void testBuildQuery() throws UnsupportedEncodingException { Map<String,String> params = Maps.newTreeMap(); params.put("key1", "val1"); params.put("key2", "val2"); String query = HttpUtil.buildQuery(params); assertEquals(uri.getQuery(), query); }