static String buildRedirect(String redirectUri, Map<String, Object> params) {
        String paramsString = params.entrySet()
                                    .stream()
                                    .map(e -> e.getKey() + "=" + urlEncode(String.valueOf(e.getValue())))
                                    .collect(Collectors.joining("&"));
        if (redirectUri.contains("?")) {
            return redirectUri + "&" + paramsString;
        }
        return redirectUri + "?" + paramsString;
    }
@Test
    public void testBuildRedirect() {
        String url = OAuth2AuthorizeController.buildRedirect("http://hsweb.me/callback", Collections.singletonMap("code", "1234"));

        assertEquals(url,"http://hsweb.me/callback?code=1234");
    }