@Test public void test_UrlBuilder_AlreadyHasQuery_WithMultipleQueries() { String baseURL = "http: Map<String, String> queryParams = new HashMap<>(); queryParams.put("search_query", "mobile linux"); queryParams.put("subject", "Architecture"); String expected = "http: String output = UrlUtil.buildUrlWithQueryParams(logger, baseURL, queryParams); assertEquals(expected, output); }
public static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl, @NonNull Map<String, String> queryParams) { final Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); for (Map.Entry<String, String> entry : queryParams.entrySet()) { uriBuilder.appendQueryParameter(entry.getKey(), entry.getValue()); } final String finalUrl = uriBuilder.build().toString(); logger.debug("URL: " + finalUrl); return finalUrl; }
UrlUtil { public static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl, @NonNull Map<String, String> queryParams) { final Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); for (Map.Entry<String, String> entry : queryParams.entrySet()) { uriBuilder.appendQueryParameter(entry.getKey(), entry.getValue()); } final String finalUrl = uriBuilder.build().toString(); logger.debug("URL: " + finalUrl); return finalUrl; } }
UrlUtil { public static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl, @NonNull Map<String, String> queryParams) { final Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); for (Map.Entry<String, String> entry : queryParams.entrySet()) { uriBuilder.appendQueryParameter(entry.getKey(), entry.getValue()); } final String finalUrl = uriBuilder.build().toString(); logger.debug("URL: " + finalUrl); return finalUrl; }  }
UrlUtil { public static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl, @NonNull Map<String, String> queryParams) { final Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); for (Map.Entry<String, String> entry : queryParams.entrySet()) { uriBuilder.appendQueryParameter(entry.getKey(), entry.getValue()); } final String finalUrl = uriBuilder.build().toString(); logger.debug("URL: " + finalUrl); return finalUrl; }  static String makeAbsolute(String url, String base); static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl,
                                                 @NonNull Map<String, String> queryParams); @NonNull static Map<String, String> getQueryParams(@NonNull Uri uri); static String removeQueryParameterFromURL(@NonNull String url, @NonNull String queryParam); }
UrlUtil { public static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl, @NonNull Map<String, String> queryParams) { final Uri.Builder uriBuilder = Uri.parse(baseUrl).buildUpon(); for (Map.Entry<String, String> entry : queryParams.entrySet()) { uriBuilder.appendQueryParameter(entry.getKey(), entry.getValue()); } final String finalUrl = uriBuilder.build().toString(); logger.debug("URL: " + finalUrl); return finalUrl; }  static String makeAbsolute(String url, String base); static String buildUrlWithQueryParams(@NonNull Logger logger, @NonNull String baseUrl,
                                                 @NonNull Map<String, String> queryParams); @NonNull static Map<String, String> getQueryParams(@NonNull Uri uri); static String removeQueryParameterFromURL(@NonNull String url, @NonNull String queryParam); static final String QUERY_PARAM_SEARCH; static final String QUERY_PARAM_SUBJECT; }