### Question:
StringUri { public static Map<String, String> getQueryParamsFromUri(String uri) { Map<String, String> queryParams = new HashMap<>(); if (!uri.contains("?")) { return queryParams; } String paramsString = uri.split("\\?")[1]; String[] paramsWithValues = paramsString.split("&"); for (String paramWithValueString : paramsWithValues) { String[] paramAndValue = paramWithValueString.split("=", 2); queryParams.put(paramAndValue[0], paramAndValue.length > 1 ? decode(paramAndValue[1]) : null); } return queryParams; } private  StringUri(); static String fromElements(Object... elements); static String withQuery(String uri, Map<String, ?> requestParams); static String withQuery(String uri, String paramName, String paramValue); static Map<String, String> getQueryParamsFromUri(String uri); static String decode(String url); static boolean isUri(String stringToCheck); static boolean containsProtocol(String urlToCheck); static boolean containsQueryParam(String uri, String paramName); static String appendQueryParam(String uri, String paramName, String paramValue); static String removeAllQueryParams(String uri); static Optional<String> getVersion(String uri); static String copyQueryParams(String sourceUri, String targetUri);  }### Answer:
@Test void getQueryParamsFromUriWithoutParams() { assertThat(StringUri.getQueryParamsFromUri("http: .isEmpty(); }
@Test void getQueryParamsFromUriWithOneParam() { String key = "q"; String value = "2012-12-21"; String uri = String.format("http: Map<String, String> params = StringUri.getQueryParamsFromUri(uri); assertThat(params).hasSize(1) .containsEntry(key, value); }
@Test void getQueryParamsFromUriWithMoreThenOneParam() { String key1 = "q"; String value1 = "2012-12-21"; String key2 = "k"; String value2 = "someKey"; String key3 = "zz"; String value3 = "someKeyZZ"; String uri = String.format("http: key1, value1, key2, value2, key3, value3); Map<String, String> params = StringUri.getQueryParamsFromUri(uri); assertThat(params).hasSize(3) .containsEntry(key1, value1) .containsEntry(key2, value2) .containsEntry(key3, value3); }
@Test void getQueryParamsFromUriWithEqualSignInsideParamValue() { String key = "q"; String value = "2012=12=21"; String uri = String.format("http: Map<String, String> params = StringUri.getQueryParamsFromUri(uri); assertThat(params).hasSize(1) .containsEntry(key, value); }