Skip to content

Commit

Permalink
some polish
Browse files Browse the repository at this point in the history
  • Loading branch information
eiswind committed Feb 13, 2024
1 parent 45c1b2e commit f186c75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ public class SomeWildApiClient {
private RestClient restClient;

public SomeWildApiClient(
// baseUrl must be dynamic, so we can switch
// between the real API and the mock server
@Value("${some-wild-api.url}") String baseUrl,
@Value("${some-wild-api.url}") // <1> Die baseUrl muss dynamisch sein, damit wir zwischen der echten API und dem Mock umschalten können.
String baseUrl,
RestClient.Builder builder
) {
this.restClient = builder.baseUrl(baseUrl).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ void apiTest() {

var result = apiClient.invokeApi();

mockServer.verify();

assertThat(result).isEqualTo(body);

mockServer.verify(); // <1> Zuletzt wird geprüft, ob die Anfrage an den MockServer gesendet wurde.
}
}
// end::snip[]
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ void apiTest() {

var body = "This API is very wild. It's not safe to use it.";

wiremock.stubFor(get("/some-wild-api").willReturn(aResponse()

wiremock.stubFor(get("/some-wild-api") // <1> Zuerst wird der Request definiert, auf den das Mock reagieren soll.
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody(body)
));
Expand Down

0 comments on commit f186c75

Please sign in to comment.