### Question:
GatewayServlet extends HttpServlet { protected static final QueryMap parseApiRequestQueryParams(String queryString) { QueryMap rval = new QueryMap(); if (queryString != null) { try { String[] pairSplit = queryString.split("&"); for (String paramPair : pairSplit) { int idx = paramPair.indexOf("="); String key, value; if (idx != -1) { key = URLDecoder.decode(paramPair.substring(0, idx), "UTF-8"); value = URLDecoder.decode(paramPair.substring(idx + 1), "UTF-8"); } else { key = URLDecoder.decode(paramPair, "UTF-8"); value = null; } rval.add(key, value); } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } return rval; } GatewayServlet();   }### Answer:
@Test public void testParseApiRequestQueryParams() { QueryMap paramMap = GatewayServlet.parseApiRequestQueryParams(null); Assert.assertNotNull(paramMap); paramMap = GatewayServlet.parseApiRequestQueryParams("param1"); Assert.assertNull(paramMap.get("param1")); paramMap = GatewayServlet.parseApiRequestQueryParams("param1=value1"); Assert.assertEquals("value1", paramMap.get("param1")); paramMap = GatewayServlet.parseApiRequestQueryParams("param1=value1&param2"); Assert.assertEquals("value1", paramMap.get("param1")); Assert.assertNull(paramMap.get("param2")); paramMap = GatewayServlet.parseApiRequestQueryParams("param1=value1&param2=value2"); Assert.assertEquals("value1", paramMap.get("param1")); Assert.assertEquals("value2", paramMap.get("param2")); paramMap = GatewayServlet.parseApiRequestQueryParams("param1=value1&param2=value2&param3=value3"); Assert.assertEquals("value1", paramMap.get("param1")); Assert.assertEquals("value2", paramMap.get("param2")); Assert.assertEquals("value3", paramMap.get("param3")); paramMap = GatewayServlet.parseApiRequestQueryParams("param1=hello%20world&param2=hello+world&param3=hello%20world&strangekeywith%3D%2B%26%3F=strangevaluewith%3D%2B%26%3F"); Assert.assertEquals("hello world", paramMap.get("param1")); Assert.assertEquals("hello world", paramMap.get("param2")); Assert.assertEquals("hello world", paramMap.get("param3")); Assert.assertEquals("strangevaluewith=+&?", paramMap.get("strangekeywith=+&?")); }