Spring Boot Rest Client - How to test HTTP calls using @RestClientTest

preview_player
Показать описание
In this tutorial you will learn how to test Rest Client calls in Spring Boot using the @RestClientTest annotation.

🔗Resources & Links mentioned in this video:

👋🏻Connect with me:

Рекомендации по теме
Комментарии
Автор

Nice. Is it possible to make another video regarding how we do mock of APIs that are being protected OAuth2/OIDC and CSRF enabled?

assaduzzaman_dsi
Автор

BTW, truly appreciate you taking the time to do this. :)

codemonkey
Автор

Great information! Maybe do the same wit the JDBC Client and mocking it up?

andytael
Автор

Heyyy, pls do more videos about testing with more advanced topics, especially how to test when we have different requests at the same time for same method in a certain controller that talks to the client API, (also pls what is the name of plugin you use in intellij to autocomplete for you more than 1 line of code ) ^^ from Morocco, you're amazing Mr Dan Vega

AlessiaCaraFans
Автор

Nice video. Do You know a good plugin for intellij for owasp security analyzer? Maybe a series of videos with the top ten attacks

gallardofabian
Автор

Could you, please, make a video on how to setup RestClient to use proxy with and without authentication?

BabaykaMoscow
Автор

Hi Dan. Nice video. I have one question. When I write tests using give/when/then sections I put the mock configuration in the 'given' section. In the 'when' section there is the execution of the tested objected only. What do you think about that?

marba
Автор

This is great, thank you so much for this. When we are doing the Integration test and we are using @SpringBootTest, we just use the regular rest client to test my own controllers ?

peshutanpavri
Автор

When I run your tutorial WITHOUT adding any specific type of HTTP client, it still calls the actual service instead of the Mock Serivce. The test of course fails with expected 2 but had 100. Has something changed since this video was published?

codemonkey
Автор

Just downloaded the tutorial (with no changes) and the Test failed with 100 replies - indicating that the live server was being contacted (not the mocked server). A couple of other people seem to have had the same issue. Has there been a fix for this issue since the video was published? I commented out the JdkClientHttpRequestFactory as suggested in the video - which works - but isn't much use when your other videos recommend this substitution - meaning that I can't test the code I'm writing.

JohnSmith-zsow
Автор

Could you point us to an example where the RestClient is invoking an API with HTTP method as POST method instead of GET?

OneClickLabs
Автор

This is great. But I am stuck when I have two rest clients in my application. The documentation suggests I should use the This gets rid of the error messages and in the customizer I see my the mockservers for each of my clients. But I am stuck at how to get the correct server for each client. You can get a server out of the customizer with getServer(), but this takes a RestClient.Builder(??).

I can get the "first" server and the "second" server out of the HashMap that the customizer provides, but the tests are too flaky. Sometimes client A is the first entry and sometimes client B is the first entry.

Can you help me?

Jallallalla
Автор

Where do you usually use the @Component? I know the @Service is for the business layers, what im quite confused with the correct usage for @Component.

nickcruz
Автор

How to test 404, 401 and 500 http status ?

leonardoncintra
Автор

why not to use "REST Assured" lib?

blaaarpu
Автор

what is theme of dan vega ıs there any one knows it

MustafaKanzii
Автор

hi Dan, i got a question, what if i have configured two rest client in a configuration file, and i want to test one of them, how should i do

AlexWen-hr
Автор

would be more usefull if you could create rest client with properties files rather than put constant url ...

public PostClient(RestClient.Builder builder, RestClientProperties properties) {
this.restClient = builder
.baseUrl(properties.url())
.build();
}




Does not work and produce: No qualifying bean of type 'java.lang.String' available ...

dariuszchmiea