@Test
public void testGetHtmlEscapedURIWithQueryString() throws Exception {

  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  String targetUri = "/test/path";
  Mockito.when(request.getCharacterEncoding()).thenReturn(null);
  Mockito.when(request.getRequestURI()).thenReturn(targetUri);
  Map<String, String> paramResultMap = new HashMap<>();
  paramResultMap.put("param1=x", targetUri + "?" + "param1=x");
  paramResultMap
      .put("param1=x&param2=y", targetUri + "?" + "param1=x&amp;param2=y");
  paramResultMap.put("param1=x&param2=y&param3=x+y",
      targetUri + "?" + "param1=x&amp;param2=y&amp;param3=x+y");
  for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
    Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
    String uri = WebAppUtils.getHtmlEscapedURIWithQueryString(request);
    Assert.assertEquals(entry.getValue(), uri);
  }
}