|
| 1 | +package com.devhire.ai.config; |
| 2 | + |
| 3 | +import com.devhire.ai.client.AnthropicClaudeClient; |
| 4 | +import com.devhire.ai.tool.JobSearchTool; |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | +import org.springframework.boot.autoconfigure.AutoConfigurations; |
| 7 | +import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
| 8 | +import org.springframework.boot.webclient.autoconfigure.WebClientAutoConfiguration; |
| 9 | +import org.springframework.context.annotation.Configuration; |
| 10 | +import org.springframework.context.annotation.Import; |
| 11 | +import org.springframework.web.reactive.function.client.WebClient; |
| 12 | + |
| 13 | +import static org.assertj.core.api.Assertions.assertThat; |
| 14 | + |
| 15 | +class AiWebClientConfigurationTest { |
| 16 | + |
| 17 | + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() |
| 18 | + .withConfiguration(AutoConfigurations.of(WebClientAutoConfiguration.class)) |
| 19 | + .withBean(AiProperties.class, AiProperties::new) |
| 20 | + .withUserConfiguration(ClientConfiguration.class); |
| 21 | + |
| 22 | + @Test |
| 23 | + void autoConfiguresWebClientBuilderForAiClients() { |
| 24 | + contextRunner.run(context -> { |
| 25 | + assertThat(context).hasSingleBean(WebClient.Builder.class); |
| 26 | + assertThat(context).hasSingleBean(AnthropicClaudeClient.class); |
| 27 | + assertThat(context).hasSingleBean(JobSearchTool.class); |
| 28 | + }); |
| 29 | + } |
| 30 | + |
| 31 | + @Configuration(proxyBeanMethods = false) |
| 32 | + @Import({AnthropicClaudeClient.class, JobSearchTool.class}) |
| 33 | + static class ClientConfiguration { |
| 34 | + } |
| 35 | +} |
0 commit comments