### Question:
HttpUtils { public static String encodeParameters(Request<?> request) { if (request.getParameters().isEmpty()) { return null; } final StringBuilder sb = new StringBuilder(); boolean first = true; try { for (final Entry<String, String> entry : request.getParameters().entrySet()) { final String encodedName = URLEncoder.encode(entry.getKey(), DEFAULT_ENCODING); final String value = entry.getValue(); final String encodedValue = value == null ? "" : URLEncoder.encode(value, DEFAULT_ENCODING); if (!first) { sb.append("&"); } else { first = false; } sb.append(encodedName).append("=").append(encodedValue); } } catch (final UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } return sb.toString(); }  static String urlEncode(final String value, final boolean path); static String urlDecode(final String value); static boolean isUsingNonDefaultPort(URI uri); static boolean usePayloadForQueryParameters(Request<?> request); static String encodeParameters(Request<?> request); static String appendUri(String baseUri, String path); static String appendUri(final String baseUri, String path,
            final boolean escapeDoubleSlash); static InputStream fetchFile(
            final URI uri,
            final ClientConfiguration config);  }### Answer:
@Test public void testEncodeParameters() { final Request<?> request = new DefaultRequest<String>("TestRequest"); request.addParameter("FirstKey", "FirstValue"); request.addParameter("LastKey", "LastValue"); final String encoded = HttpUtils.encodeParameters(request); assertEquals(encoded, "FirstKey=FirstValue&LastKey=LastValue"); }
@Test public void testEncodeParametersReturnsNullOnEmptyParameters() { final Request<?> request = new DefaultRequest<String>("TestRequest"); final String encoded = HttpUtils.encodeParameters(request); assertNull(encoded); }