use of org.springframework.web.client.RequestCallback in project incubator-servicecomb-java-chassis by apache.
the class CseRestTemplate method httpEntityCallback.
@Override
protected <T> RequestCallback httpEntityCallback(Object requestBody) {
RequestCallback callback = super.httpEntityCallback(requestBody);
CseRequestCallback cseCallback = new CseRequestCallback(requestBody, callback);
return cseCallback;
}
use of org.springframework.web.client.RequestCallback in project java-chassis by ServiceComb.
the class TestRestTemplateWrapper method executeWithUnderlyingRestTemplate.
@Test
public void executeWithUnderlyingRestTemplate() {
RequestCallback requestCallback = clientHttpRequest -> {
};
ResponseExtractor<ResponseEntity<String>> responseExtractor = clientHttpResponse -> responseEntity;
ResponseEntity<String> actual;
for (HttpMethod method : httpMethods) {
when(underlying.execute(url, method, requestCallback, responseExtractor, param1, param2)).thenReturn(responseEntity);
actual = wrapper.execute(url, method, requestCallback, responseExtractor, param1, param2);
assertThat(actual, is(responseEntity));
verify(underlying).execute(url, method, requestCallback, responseExtractor, param1, param2);
when(underlying.execute(url, method, requestCallback, responseExtractor, paramsMap)).thenReturn(responseEntity);
actual = wrapper.execute(url, method, requestCallback, responseExtractor, paramsMap);
assertThat(actual, is(responseEntity));
verify(underlying).execute(url, method, requestCallback, responseExtractor, paramsMap);
when(underlying.execute(uri, method, requestCallback, responseExtractor)).thenReturn(responseEntity);
actual = wrapper.execute(uri, method, requestCallback, responseExtractor);
assertThat(actual, is(responseEntity));
verify(underlying).execute(uri, method, requestCallback, responseExtractor);
}
}
use of org.springframework.web.client.RequestCallback in project java-chassis by ServiceComb.
the class CseRestTemplate method getForObject.
@Override
@Nullable
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
RequestCallback requestCallback = acceptHeaderRequestCallback(responseType);
CseHttpMessageConverterExtractor<T> responseExtractor = new CseHttpMessageConverterExtractor<>();
return execute(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables);
}
use of org.springframework.web.client.RequestCallback in project java-chassis by ServiceComb.
the class CseRestTemplate method httpEntityCallback.
@Override
public <T> RequestCallback httpEntityCallback(Object requestBody) {
RequestCallback callback = super.httpEntityCallback(requestBody);
CseRequestCallback cseCallback = new CseRequestCallback(requestBody, callback, null);
return cseCallback;
}
use of org.springframework.web.client.RequestCallback in project java-chassis by ServiceComb.
the class CseRestTemplate method postForObject.
// HEAD
// no override
// POST
@Override
@Nullable
public <T> T postForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables) throws RestClientException {
RequestCallback requestCallback = httpEntityCallback(request, responseType);
CseHttpMessageConverterExtractor<T> responseExtractor = new CseHttpMessageConverterExtractor<>();
return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables);
}
Aggregations