Skip to content

Commit

Permalink
Add tests for @LoadBalanced clients defined in autoconfigurations.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek committed Jan 12, 2024
1 parent c45e465 commit 7fc64a0
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ void multipleRestTemplates() {
void multipleRestClientBuilders() {
applicationContextRunner.withUserConfiguration(TwoRestTemplatesAndTwoRestClientBuilders.class).run(context -> {
final Map<String, RestClient.Builder> restClientBuilders = context.getBeansOfType(RestClient.Builder.class);
final Map<String, RestTemplate> restTemplates = context.getBeansOfType(RestTemplate.class);

assertThat(restClientBuilders).isNotNull();
assertThat(restClientBuilders.values()).hasSize(2);
Expand All @@ -115,19 +114,6 @@ void multipleRestClientBuilders() {
assertThat(two.nonLoadBalancedRestClientBuilder).isNotNull();
two.nonLoadBalancedRestClientBuilder
.requestInterceptors(interceptors -> assertThat(interceptors).isEmpty());

assertThat(restTemplates).isNotNull();
Collection<RestTemplate> templates = restTemplates.values();
assertThat(templates).hasSize(2);

TwoRestTemplatesAndTwoRestClientBuilders.Two twoRestTemplate = context
.getBean(TwoRestTemplatesAndTwoRestClientBuilders.Two.class);

assertThat(twoRestTemplate.loadBalanced).isNotNull();
assertLoadBalanced(twoRestTemplate.loadBalanced);

assertThat(twoRestTemplate.nonLoadBalanced).isNotNull();
assertThat(twoRestTemplate.nonLoadBalanced.getInterceptors()).isEmpty();
});
}

Expand All @@ -138,6 +124,7 @@ void restTemplatesAndRestClientsFromUsersAutoConfiguration() {
.run(context -> {
final Map<String, RestClient.Builder> restClientBuilders = context
.getBeansOfType(RestClient.Builder.class);
final Map<String, RestTemplate> restTemplates = context.getBeansOfType(RestTemplate.class);

assertThat(restClientBuilders).isNotNull();
assertThat(restClientBuilders.values()).hasSize(2);
Expand All @@ -151,6 +138,19 @@ void restTemplatesAndRestClientsFromUsersAutoConfiguration() {
assertThat(two.nonLoadBalancedRestClientBuilder).isNotNull();
two.nonLoadBalancedRestClientBuilder
.requestInterceptors(interceptors -> assertThat(interceptors).isEmpty());

assertThat(restTemplates).isNotNull();
Collection<RestTemplate> templates = restTemplates.values();
assertThat(templates).hasSize(2);

TwoRestTemplatesAndTwoRestClientBuilders.Two twoRestTemplate = context
.getBean(TwoRestTemplatesAndTwoRestClientBuilders.Two.class);

assertThat(twoRestTemplate.loadBalanced).isNotNull();
assertLoadBalanced(twoRestTemplate.loadBalanced);

assertThat(twoRestTemplate.nonLoadBalanced).isNotNull();
assertThat(twoRestTemplate.nonLoadBalanced.getInterceptors()).isEmpty();
});
}

Expand Down

0 comments on commit 7fc64a0

Please sign in to comment.