PhabricatorHttpClient { public <T extends ResultWithError> T postEntityAndCheckResponse( Method method, HttpEntity<MultiValueMap<String, Object>> httpEntity, Class<T> clazz) throws PhabricatorException { String url = getUrl(method.getMethod()); T responseWithError = restTemplate.postForObject( url, httpEntity, clazz); checkNoError(responseWithError); return responseWithError; } PhabricatorHttpClient(String baseUrl, String authToken); T postEntityAndCheckResponse(
            Method method,
            HttpEntity<MultiValueMap<String, Object>> httpEntity,
            Class<T> clazz); HttpEntity<MultiValueMap<String, Object>> getHttpEntityFormUrlEncoded(); HttpEntity<MultiValueMap<String, Object>> getConstraintsForPHID(String phid); HttpEntity<MultiValueMap<String, Object>> withId(String id);  }
@Test public void postEntityAndCheckResponse() { ResultWithError objectResultWithError = new ResultWithError(); Mockito.doReturn(objectResultWithError).when(mockRestTemplate).postForObject( eq("https: any(), eq(ResultWithError.class)); ResultWithError resultWithError = phabricatorHttpClient.postEntityAndCheckResponse( Method.DIFFERENTIAL_REVISION_SEARCH, phabricatorHttpClient.getHttpEntityFormUrlEncoded(), ResultWithError.class); assertEquals(objectResultWithError, resultWithError); }