use of cn.taketoday.web.client.ResponseErrorHandler in project today-infrastructure by TAKETODAY.
the class RestTemplateBuilderTests method errorHandlerShouldApply.
@Test
void errorHandlerShouldApply() {
ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
RestTemplate template = this.builder.errorHandler(errorHandler).build();
assertThat(template.getErrorHandler()).isSameAs(errorHandler);
}
use of cn.taketoday.web.client.ResponseErrorHandler in project today-infrastructure by TAKETODAY.
the class RestTemplateBuilderTests method customizerShouldBeAppliedAtTheEnd.
@Test
void customizerShouldBeAppliedAtTheEnd() {
ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
this.builder.interceptors(this.interceptor).messageConverters(this.messageConverter).rootUri("http://localhost:8080").errorHandler(errorHandler).basicAuthentication("spring", "boot").requestFactory(() -> requestFactory).customizers((restTemplate) -> {
assertThat(restTemplate.getInterceptors()).hasSize(1);
assertThat(restTemplate.getMessageConverters()).contains(this.messageConverter);
assertThat(restTemplate.getUriTemplateHandler()).isInstanceOf(RootUriTemplateHandler.class);
assertThat(restTemplate.getErrorHandler()).isEqualTo(errorHandler);
ClientHttpRequestFactory actualRequestFactory = restTemplate.getRequestFactory();
assertThat(actualRequestFactory).isInstanceOf(InterceptingClientHttpRequestFactory.class);
ClientHttpRequestInitializer initializer = restTemplate.getHttpRequestInitializers().get(0);
assertThat(initializer).isInstanceOf(RestTemplateBuilderClientHttpRequestInitializer.class);
}).build();
}
use of cn.taketoday.web.client.ResponseErrorHandler in project today-framework by TAKETODAY.
the class RestTemplateBuilderTests method errorHandlerShouldApply.
@Test
void errorHandlerShouldApply() {
ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
RestTemplate template = this.builder.errorHandler(errorHandler).build();
assertThat(template.getErrorHandler()).isSameAs(errorHandler);
}
use of cn.taketoday.web.client.ResponseErrorHandler in project today-framework by TAKETODAY.
the class RestTemplateBuilderTests method customizerShouldBeAppliedAtTheEnd.
@Test
void customizerShouldBeAppliedAtTheEnd() {
ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
this.builder.interceptors(this.interceptor).messageConverters(this.messageConverter).rootUri("http://localhost:8080").errorHandler(errorHandler).basicAuthentication("spring", "boot").requestFactory(() -> requestFactory).customizers((restTemplate) -> {
assertThat(restTemplate.getInterceptors()).hasSize(1);
assertThat(restTemplate.getMessageConverters()).contains(this.messageConverter);
assertThat(restTemplate.getUriTemplateHandler()).isInstanceOf(RootUriTemplateHandler.class);
assertThat(restTemplate.getErrorHandler()).isEqualTo(errorHandler);
ClientHttpRequestFactory actualRequestFactory = restTemplate.getRequestFactory();
assertThat(actualRequestFactory).isInstanceOf(InterceptingClientHttpRequestFactory.class);
ClientHttpRequestInitializer initializer = restTemplate.getHttpRequestInitializers().get(0);
assertThat(initializer).isInstanceOf(RestTemplateBuilderClientHttpRequestInitializer.class);
}).build();
}
Aggregations