@Test public void queryparam_without_value_returns_list_containing_null_value() { final String uriResourcePath = "/foo/bar"; final String uriResourcePathWithParams = uriResourcePath + "?param"; final Request<Object> request = new DefaultRequest<Object>(null, null); Assert.assertEquals(uriResourcePath, UriResourcePathUtils.addStaticQueryParamtersToRequest(request, uriResourcePathWithParams)); Assert.assertTrue(request.getParameters().containsKey("param")); Assert.assertEquals(Arrays.asList((String)null), request.getParameters().get("param")); }
public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; } }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }  }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }  static String addStaticQueryParamtersToRequest(final Request<?> request,
                                                        final String uriResourcePath); static URI updateUriHost(URI uri, String newHostPrefix); }
UriResourcePathUtils { public static String addStaticQueryParamtersToRequest(final Request<?> request, final String uriResourcePath) { if (request == null || uriResourcePath == null) { return null; } String resourcePath = uriResourcePath; int index = resourcePath.indexOf("?"); if (index != -1) { String queryString = resourcePath.substring(index + 1); resourcePath = resourcePath.substring(0, index); for (String s : queryString.split("[;&]")) { index = s.indexOf("="); if (index != -1) { request.addParameter(s.substring(0, index), s.substring(index + 1)); } else { request.addParameter(s, (String)null); } } } return resourcePath; }  static String addStaticQueryParamtersToRequest(final Request<?> request,
                                                        final String uriResourcePath); static URI updateUriHost(URI uri, String newHostPrefix);  }