Mockito.when(httpRequest.getQueryString()).thenReturn(httpsUrl.getQuery());
final Url url = Url.parse(httpsUrl.getPath() + "?" + httpsUrl.getQuery());
final ServletWebRequest webRequest = new ServletWebRequest(httpRequest, "", url);
final IRequestCycle requestCycle = Mockito.mock(IRequestCycle.class);
Mockito.when(requestCycle.getRequest()).thenReturn(webRequest);
HttpsConfig httpsConfig = new HttpsConfig(80, 1443);
// request secure communication (over https)
final SwitchProtocolRequestHandler handler = new SwitchProtocolRequestHandler(
Protocol.HTTPS, httpsConfig);
final WebResponse webResponse = Mockito.mock(WebResponse.class);
Mockito.when(requestCycle.getResponse()).thenReturn(webResponse);
handler.respond(requestCycle);
Mockito.verify(webResponse).sendRedirect(httpsUrl.toString());
}