@Test public void static_queryparams_in_path_added_to_request(){ final String uriResourcePath = "/foo/bar"; final String uriResourcePathWithParams = uriResourcePath + "?param1=value1&param2=value2"; final Request<Object> request = new DefaultRequest<Object> (null, null); Assert.assertEquals(uriResourcePath, UriResourcePathUtils .addStaticQueryParamtersToRequest(request, uriResourcePathWithParams)); Assert.assertTrue(request.getParameters().containsKey("param1")); Assert.assertTrue(request.getParameters().containsKey("param2")); Assert.assertEquals(Arrays.asList("value1"), request.getParameters().get("param1")); Assert.assertEquals(Arrays.asList("value2"), request.getParameters().get("param2")); }
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); }
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);  }