ControlPointApiClient { public <R> R postUrlencoded( final String path, final List<NameValuePair> queryParams, final List<NameValuePair> bodyParams, final Class<R> resultType ) throws ControlPointApiException { return performAuthenticatedRequest( buildUrlencodedPostRequest(path, queryParams, bodyParams), resultType); }  R get(
        final String path,
        final List<NameValuePair> queryParams,
        final Class<R> resultType
    ); R postUrlencoded(
        final String path,
        final List<NameValuePair> queryParams,
        final List<NameValuePair> bodyParams,
        final Class<R> resultType
    );  }
@Test public void testPostUrlencoded() throws ControlPointApiException, IOException { final int result = defaultCPClient.postUrlencoded("copy", Arrays.asList( new BasicNameValuePair("version", "3"), new BasicNameValuePair("format", "standard") ), Arrays.asList( new BasicNameValuePair("when", "tomorrow"), new BasicNameValuePair("why", "backup") ), Integer.class); final List<HttpUriRequest> requests = getRequests(2); Assert.assertEquals("should be POST", "POST", requests.get(1).getMethod()); final HttpPost req = (HttpPost) requests.get(1); Assert.assertEquals("should have correct URL", "http: Assert.assertEquals("should include auth token", "Bearer the token", req.getFirstHeader(HttpHeaders.AUTHORIZATION).getValue()); Assert.assertEquals("should have correct body", "when=tomorrow&why=backup", IOUtils.toString(req.getEntity().getContent())); Assert.assertEquals("should parse result", 456, result); }