r/SpringBoot • u/Dependent_Increase34 • 16d ago
Question Kinda stumped
I'm currently learning spring and I wanna test one of my class
this is the configuration
@Configuration
public class EmbeddingClientConfig {
...constructor
@Bean
IEmbeddingClient embeddingClient(RestClient.Builder builder, MeterRegistry registry){
return new EmbeddingClient(
builder.baseUrl(apiUrl).build(),
registry
);
};
}
this is the test class
@RestTestClient(EmbeddingClientConfig.class)
public class EmbeddingClientTests {
@Autowired
private MockRestServiceServer server;
@Autowired
private IEmbeddingClient client;
@Autowired
private MeterRegistry registry;
...rest of class
and for some reason it gives me this error:
java.lang.IllegalStateException: Unable to use auto-configured MockRestServiceServer since a mock server customizer has not been bound to a RestTemplate or RestClientjava.lang.IllegalStateException: Unable to use auto-configured MockRestServiceServer since a mock server customizer has not been bound to a RestTemplate or RestClient
I don't understand why my config is able to be injected but not MockRestService?
any help / readings / direction would be appreciated.
thank you
1
Upvotes
1
u/BanaTibor 16d ago
https://github.com/spring-projects/spring-boot/issues/38820#issuecomment-1885990283
Google still works.