Fixed samples

This commit is contained in:
Marcin Grzejszczak
2022-05-05 15:42:09 +02:00
parent 109ec516c2
commit 44c37d5a4d
4 changed files with 15 additions and 20 deletions

View File

@@ -26,7 +26,7 @@
<module>contracts</module>
<module>restdocs</module>
<module>dsl</module>
<!-- <module>webclient</module> -->
<module>webclient</module>
</modules>
<build>

View File

@@ -180,7 +180,7 @@
</pluginRepositories>
<profiles>
<profile>
<!--<profile>
<id>integration</id>
<build>
<plugins>
@@ -198,7 +198,7 @@
<argument>clean</argument>
<argument>build</argument>
<argument>publishToMavenLocal</argument>
<!-- TODO: Remove -->
&lt;!&ndash; TODO: Remove &ndash;&gt;
<argument>-x</argument>
<argument>test</argument>
<argument>
@@ -214,7 +214,7 @@
</plugin>
</plugins>
</build>
</profile>
</profile>-->
<profile>
<id>windows</id>
<build>

View File

@@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters;
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
@@ -32,7 +31,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.json.JacksonTester;
import org.springframework.http.MediaType;
import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.reactive.function.BodyInserters;
@@ -69,8 +67,7 @@ public class StubGeneratorTests {
.jsonPath("$.rejectionReason").isEqualTo("Amount too high")
.consumeWith(verify().jsonPath("$.clientId")
.jsonPath("$[?(@.loanAmount > 1000)]")
.contentType(MediaType.valueOf("application/vnd.fraud.v1+json"))
.stub("markClientAsFraud"))
.contentType(MediaType.valueOf("application/vnd.fraud.v1+json")))
.consumeWith(
WebTestClientRestDocumentation.document("markClientAsFraud"));
}
@@ -87,8 +84,7 @@ public class StubGeneratorTests {
.jsonPath("$.rejectionReason").doesNotExist()
.consumeWith(verify().jsonPath("$.clientId")
.jsonPath("$[?(@.loanAmount <= 1000)]")
.contentType(MediaType.valueOf("application/vnd.fraud.v1+json"))
.stub("markClientAsNotFraud"))
.contentType(MediaType.valueOf("application/vnd.fraud.v1+json")))
.consumeWith(
WebTestClientRestDocumentation.document("markClientAsNotFraud"));
}

View File

@@ -209,16 +209,15 @@ class YamlToContracts {
private void handleQueryParameters(YamlContract yamlContract, Url url) {
if (yamlContract.request.queryParameters != null) {
url.queryParameters(
(queryParameters -> yamlContract.request.queryParameters.forEach((key, value) -> {
if (value instanceof List) {
((List<?>) value).forEach(
v -> queryParameters.parameter(key, queryParamValue(yamlContract, key, v)));
}
else {
queryParameters.parameter(key, queryParamValue(yamlContract, key, value));
}
})));
url.queryParameters((queryParameters -> yamlContract.request.queryParameters.forEach((key, value) -> {
if (value instanceof List) {
((List<?>) value)
.forEach(v -> queryParameters.parameter(key, queryParamValue(yamlContract, key, v)));
}
else {
queryParameters.parameter(key, queryParamValue(yamlContract, key, value));
}
})));
}
}