TankHttpUtil { public static String getQueryString(Map<String, String> urlVariables) { if (urlVariables != null && !urlVariables.isEmpty()) { return "?" + urlVariables.entrySet().stream() .map(entry -> { try { return URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8.name()) + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException ex) { LOG.warn("Unable to set query string value: " + ex.getMessage()); } return ""; }) .collect(joining("&")); } return ""; }  static URL buildUrl(String protocol, String host, int port, String path, Map<String, String> urlVariables); static String getQueryString(Map<String, String> urlVariables); static BaseResponse newResponseObject(String contentTypeHeader); static List<PartHolder> getPartsFromBody(BaseRequest request);  }
@Test public void testGetQueryString_1() throws Exception { Map<String, String> urlVariables = new HashMap(); String result = TankHttpUtil.getQueryString(urlVariables); assertNotNull(result); }
@Test public void testGetQueryString_2() throws Exception { Map<String, String> urlVariables = new HashMap(); urlVariables.put("val1", "val1"); urlVariables.put("val2", "val2"); urlVariables.put("val3", "val3"); String result = TankHttpUtil.getQueryString(urlVariables); assertNotNull(result); assertEquals( "?val3=val3&val2=val2&val1=val1", result); }
@Test public void testGetQueryString_3() throws Exception { Map<String, String> urlVariables = new HashMap(); urlVariables.put("data", "{\"val1\":\"val1\", \"val2\":\"val2\", \"val3\":\"val3\"}"); String result = TankHttpUtil.getQueryString(urlVariables); assertNotNull(result); assertEquals( "?data=%7B%22val1%22%3A%22val1%22%2C+%22val2%22%3A%22val2%22%2C+%22val3%22%3A%22val3%22%7D", result); }
@Test public void testGetQueryString_4() throws Exception { Map<String, String> urlVariables = new HashMap(); String result = TankHttpUtil.getQueryString(urlVariables); assertNotNull(result); }
@Test public void testGetQueryString_5() throws Exception { Map<String, String> urlVariables = new HashMap(); String result = TankHttpUtil.getQueryString(urlVariables); assertNotNull(result); }
@Test public void testGetQueryString_6() throws Exception { Map<String, String> urlVariables = null; String result = TankHttpUtil.getQueryString(urlVariables); assertNotNull(result); }