diff --git a/docs/modules/ROOT/pages/project-features-flows/custom-mode.adoc b/docs/modules/ROOT/pages/project-features-flows/custom-mode.adoc
index e8c9457d23..0ccb41ffd5 100644
--- a/docs/modules/ROOT/pages/project-features-flows/custom-mode.adoc
+++ b/docs/modules/ROOT/pages/project-features-flows/custom-mode.adoc
@@ -25,7 +25,7 @@ The following example shows a generated test:
package com.example.beer;
import com.example.BeerRestBase;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.http.HttpVerifier;
import org.springframework.cloud.contract.verifier.http.Request;
import org.springframework.cloud.contract.verifier.http.Response;
@@ -38,7 +38,7 @@ import static org.springframework.cloud.contract.verifier.http.Request.given;
@SuppressWarnings("rawtypes")
public class RestTest extends BeerRestBase {
- @Inject HttpVerifier httpVerifier;
+ @Autowired HttpVerifier httpVerifier;
@Test
public void validate_shouldGrantABeerIfOldEnough() throws Exception {
diff --git a/docs/modules/ROOT/pages/project-features-flows/graphql.adoc b/docs/modules/ROOT/pages/project-features-flows/graphql.adoc
index e8b7bd4b79..93b7e899b1 100644
--- a/docs/modules/ROOT/pages/project-features-flows/graphql.adoc
+++ b/docs/modules/ROOT/pages/project-features-flows/graphql.adoc
@@ -91,7 +91,8 @@ metadata:
----
====
-Adding the metadata section will change the way the default, WireMock stub is built. It will now use the Spring Cloud Contract request matcher, so that e.g. the `query` part of the GraphQL request gets compared against the real request by ignoring whitespaces.
+Adding the metadata section will change the way the default, WireMock stub is built.
+It will now use the Spring Cloud Contract request matcher, so that e.g. the `query` part of the GraphQL request gets compared against the real request by ignoring whitespaces.
[[features-graphql-producer]]
== Producer Side Setup
@@ -177,7 +178,7 @@ public class BeerControllerGraphQLTest {
.contentType(MediaType.APPLICATION_JSON)
.body(REQUEST_BODY), String.class);
- BDDAssertions.then(responseEntity.getStatusCodeValue()).isEqualTo(200);
+ BDDAssertions.then(responseEntity.getStatusCode().value()).isEqualTo(200);
}
}
diff --git a/pom.xml b/pom.xml
index 3c9a07eb86..5af7c09300 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,12 +35,12 @@
5.0.0-SNAPSHOT
5.0.4
3.3.0
- 2.3-groovy-4.0
+ 2.3-groovy-4.0
+
0.2.2
1.11.0
4.3.1
6.10.1.202505221210-r
- 1
2.38.0
5.2.1
[2.0.0,)
@@ -49,7 +49,8 @@
5.12.1
5.12.1
1.13.0
- 3.2.5
+ 3.2.5
+
4.2.0
2.39.0
1.19.8
@@ -232,11 +233,6 @@
handlebars
${handlebars.version}
-
- javax.inject
- javax.inject
- ${javax-inject.version}
-
@@ -414,9 +410,9 @@
org.sonatype.sisu
- sisu-inject-plexus
+ sisu-inject-plexus
${sisu-inject-plexus.version}
-
+
org.apache.maven.resolver
maven-resolver
@@ -632,7 +628,9 @@
netflix-candidates
Netflix Candidates
- https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates
+
+ https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates
+
false
diff --git a/spring-cloud-contract-shade/pom.xml b/spring-cloud-contract-shade/pom.xml
index c9e294dd5c..91f281a55f 100644
--- a/spring-cloud-contract-shade/pom.xml
+++ b/spring-cloud-contract-shade/pom.xml
@@ -8,7 +8,7 @@
0.3.5
4.2.0
5.0.1
- 33.0.0-jre
+ 33.4.8-jre
9.6
3.25.0
3.6.1
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-converters/src/test/groovy/org/springframework/cloud/contract/verifier/wiremock/DslToWireMockClientConverterSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-converters/src/test/groovy/org/springframework/cloud/contract/verifier/wiremock/DslToWireMockClientConverterSpec.groovy
index 932d951541..9d09b42a5a 100755
--- a/spring-cloud-contract-tools/spring-cloud-contract-converters/src/test/groovy/org/springframework/cloud/contract/verifier/wiremock/DslToWireMockClientConverterSpec.groovy
+++ b/spring-cloud-contract-tools/spring-cloud-contract-converters/src/test/groovy/org/springframework/cloud/contract/verifier/wiremock/DslToWireMockClientConverterSpec.groovy
@@ -71,8 +71,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
""")
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals('''
{"request":{"method":"PUT","urlPattern":"/[0-9]{2}"},"response":{"status":200}}
@@ -115,8 +119,12 @@ class DslToWireMockClientConverterSpec extends Specification {
]
""")
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals('''
{"request":{"url":"/multipart","method":"POST","headers":{"Content-Type":{"matches":"multipart/form-data.*"}},"bodyPatterns":[{"matches" : ".*--(.*)\\r?\\nContent-Disposition: form-data; name=\\"file\\"; filename=\\".+\\"\\r?\\n(Content-Type: .*\\r?\\n)?(Content-Transfer-Encoding: .*\\r?\\n)?(Content-Length: \\\\d+\\r?\\n)?\\r?\\n.+\\r?\\n--.*"}]},"response":{"status":200,"body":"hello","transformers":["response-template", "spring-cloud-contract" ]}}
@@ -165,25 +173,32 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- Map convertedContents = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file)))
+ Map convertedContents =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
then:
convertedContents.size() == 2
- JSONAssert.assertEquals(jsonResponse(1), convertedContents.values().first(), false)
- JSONAssert.assertEquals(jsonResponse(2), convertedContents.values().last(), false)
+ JSONAssert.assertEquals(
+ jsonResponse(1), convertedContents.values().first(), false)
+ JSONAssert.assertEquals(
+ jsonResponse(2), convertedContents.values().last(), false)
and:
- StubMapping mapping = stubMappingIsValidWireMockStub(convertedContents.values().first())
- StubMapping mapping2 = stubMappingIsValidWireMockStub(convertedContents.values().last())
+ StubMapping mapping =
+ stubMappingIsValidWireMockStub(convertedContents.values().first())
+ StubMapping mapping2 =
+ stubMappingIsValidWireMockStub(convertedContents.values().last())
and:
wireMockRule.addStubMapping(mapping)
wireMockRule.addStubMapping(mapping2)
and:
restTemplate.exchange(RequestEntity.put("${url}/1".toURI())
- .header('Content-Type', 'application/json')
- .body(""), String)
+ .header('Content-Type', 'application/json')
+ .body(""), String)
restTemplate.exchange(RequestEntity.put("${url}/2".toURI())
- .header('Content-Type', 'application/json')
- .body(""), String)
+ .header('Content-Type', 'application/json')
+ .body(""), String)
}
private String jsonResponse(int index) {
@@ -207,7 +222,8 @@ class DslToWireMockClientConverterSpec extends Specification {
when:
Map convertedContents = converter.convertContents("Test",
new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file)))
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
then:
convertedContents.isEmpty()
}
@@ -231,8 +247,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
""")
when:
- String json = converter.convertContents("test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals('''
{"request":{
@@ -300,8 +320,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
""")
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals('''
{
@@ -358,8 +382,8 @@ class DslToWireMockClientConverterSpec extends Specification {
wireMockRule.addStubMapping(mapping)
and:
restTemplate.exchange(RequestEntity.put("${url}/api/12".toURI())
- .header('Content-Type', 'application/vnd.org.springframework.cloud.contract.verifier.twitter-places-analyzer.v1+json')
- .body('''
+ .header('Content-Type', 'application/vnd.org.springframework.cloud.contract.verifier.twitter-places-analyzer.v1+json')
+ .body('''
[{
"created_at": "Sat Jul 26 09:38:57 +0000 2014",
"id": 492967299297845248,
@@ -418,8 +442,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
""")
when:
- String json = converter.convertContents("test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals('''
{"request":{"urlPath":"/foos","method":"GET"},"response":{"body":"[{\\"id\\":\\"123\\"},{\\"id\\":\\"567\\"}]"}}
@@ -429,9 +457,12 @@ class DslToWireMockClientConverterSpec extends Specification {
and:
wireMockRule.addStubMapping(mapping)
and:
- def response = restTemplate.exchange(RequestEntity.get("${url}/foos".toURI()).build(), String)
+ def response =
+ restTemplate.exchange(
+ RequestEntity.get("${url}/foos".toURI()).build(), String)
response.headers.get('Content-Type') == ['application/json']
- JSONAssert.assertEquals('''[ { "id":"123" }, { "id": "567" } ]''', response.body, false)
+ JSONAssert.assertEquals('''[ { "id":"123" }, { "id": "567" } ]''',
+ response.body, false)
}
@@ -457,8 +488,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
""")
when:
- String json = converter.convertContents("test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
noExceptionThrown()
and:
@@ -468,7 +503,9 @@ class DslToWireMockClientConverterSpec extends Specification {
and:
wireMockRule.addStubMapping(mapping)
and:
- def response = restTemplate.exchange(RequestEntity.get("${url}/foos".toURI()).build(), String)
+ def response =
+ restTemplate.exchange(
+ RequestEntity.get("${url}/foos".toURI()).build(), String)
response.body
}
@@ -504,8 +541,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals( // tag::wiremock[]
'''
@@ -541,13 +582,17 @@ class DslToWireMockClientConverterSpec extends Specification {
and:
wireMockRule.addStubMapping(mapping)
and:
- def response = restTemplate.exchange(RequestEntity.post("${url}/users/password".toURI())
- .header("Content-Type", "application/json")
- .body('''{"email":"abc@abc.com", "callback_url":"https://partners.com"}''')
- , String)
+ def response =
+ restTemplate
+ .exchange(RequestEntity.post("${url}/users/password".toURI())
+ .header("Content-Type", "application/json")
+ .body('''{"email":"abc@abc.com", "callback_url":"https://partners.com"}''')
+ , String)
response.headers.get('Content-Type') == ['application/json']
- response.statusCodeValue == 404
- JSONAssert.assertEquals('''{"code":"123123","message":"User not found by email == [not.existing@user.com]"}"''', response.body, false)
+ response.getStatusCode().value() == 404
+ JSONAssert
+ .assertEquals('''{"code":"123123","message":"User not found by email == [not.existing@user.com]"}"''',
+ response.body, false)
}
def 'should convert dsl to wiremock with stub matchers'() {
@@ -692,8 +737,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals(//tag::matchers[]
'''
@@ -764,47 +813,47 @@ class DslToWireMockClientConverterSpec extends Specification {
wireMockRule.addStubMapping(mapping)
and:
def response = restTemplate.exchange(RequestEntity.post("${url}/get".toURI())
- .header("Content-Type", "application/json")
- .body(JsonOutput.toJson([
- duck : 123,
- alpha : "abc",
- number : 123,
- aBoolean : true,
- date : "2017-01-01",
- dateTime : "2017-01-01T01:23:45",
- time : "01:02:34",
- valueWithoutAMatcher: "foo",
- valueWithTypeMatch : "string",
- list : [
- some : [
- nested: [
- json : "with value",
- anothervalue: 4
+ .header("Content-Type", "application/json")
+ .body(JsonOutput.toJson([
+ duck : 123,
+ alpha : "abc",
+ number : 123,
+ aBoolean : true,
+ date : "2017-01-01",
+ dateTime : "2017-01-01T01:23:45",
+ time : "01:02:34",
+ valueWithoutAMatcher: "foo",
+ valueWithTypeMatch : "string",
+ list : [
+ some : [
+ nested: [
+ json : "with value",
+ anothervalue: 4
+ ]
+ ],
+ someother: [
+ nested: [
+ json : "with value",
+ anothervalue: 4
+ ]
]
],
- someother: [
- nested: [
- json : "with value",
- anothervalue: 4
- ]
+ valueWithMin : [
+ 1, 2, 3
+ ],
+ valueWithMax : [
+ 1, 2, 3
+ ],
+ valueWithMinMax : [
+ 1, 2, 3
+ ],
+ valueWithOccurrence : [
+ 1, 2, 3, 4
]
- ],
- valueWithMin : [
- 1, 2, 3
- ],
- valueWithMax : [
- 1, 2, 3
- ],
- valueWithMinMax : [
- 1, 2, 3
- ],
- valueWithOccurrence : [
- 1, 2, 3, 4
- ]
- ]))
+ ]))
, String)
response.headers.get('Content-Type') == ['application/json']
- response.statusCodeValue == 200
+ response.statusCode.value() == 200
JSONAssert.assertEquals(JsonOutput.toJson([
duck : 123,
alpha : "abc",
@@ -870,8 +919,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals(
'''
@@ -906,13 +959,17 @@ class DslToWireMockClientConverterSpec extends Specification {
and:
wireMockRule.addStubMapping(mapping)
and:
- def response = restTemplate.exchange(RequestEntity.post("${url}/users/password2".toURI())
- .header("Content-Type", "application/json")
- .body('''{"email":"abc@abc.com", "callback_url":"https://partners.com"}''')
- , String)
+ def response =
+ restTemplate
+ .exchange(RequestEntity.post("${url}/users/password2".toURI())
+ .header("Content-Type", "application/json")
+ .body('''{"email":"abc@abc.com", "callback_url":"https://partners.com"}''')
+ , String)
response.headers.get('Content-Type') == ['application/json']
- response.statusCodeValue == 404
- JSONAssert.assertEquals('''{"code":"123123","message":"User not found by email == [not.existing@user.com]"}"''', response.body, false)
+ response.statusCode.value() == 404
+ JSONAssert
+ .assertEquals('''{"code":"123123","message":"User not found by email == [not.existing@user.com]"}"''',
+ response.body, false)
}
@Issue("#515")
@@ -965,8 +1022,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals(
'''
@@ -1004,13 +1065,16 @@ class DslToWireMockClientConverterSpec extends Specification {
and:
wireMockRule.addStubMapping(mapping)
and:
- def response = restTemplate.exchange(RequestEntity.post("${url}/users/password2".toURI())
- .header("Content-Type", "application/json")
- .body('''{"email":"abc@abc.com", "callback_url":"https://partners.com"}''')
- , String)
+ def response =
+ restTemplate
+ .exchange(RequestEntity.post("${url}/users/password2".toURI())
+ .header("Content-Type", "application/json")
+ .body('''{"email":"abc@abc.com", "callback_url":"https://partners.com"}''')
+ , String)
response.headers.get('Content-Type') == ['application/json;charset=UTF-8']
- response.statusCodeValue == 400
- JSONAssert.assertEquals('''{"message":"[8.2 Profile/3.7 Bad Request]"}"''', response.body, false)
+ response.statusCode.value() == 400
+ JSONAssert.assertEquals('''{"message":"[8.2 Profile/3.7 Bad Request]"}"''',
+ response.body, false)
}
@Issue("#449")
@@ -1040,8 +1104,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals(
'''
@@ -1071,7 +1139,7 @@ class DslToWireMockClientConverterSpec extends Specification {
.header("X-Smartup-Test", "asd123")
.build()
, String)
- response.statusCodeValue == 204
+ response.statusCode.value() == 204
}
@@ -1103,8 +1171,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
""")
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals("""
{
@@ -1127,10 +1199,14 @@ class DslToWireMockClientConverterSpec extends Specification {
StubMapping stubMappingIsValidWireMockStub(String mappingDefinition) {
StubMapping stubMapping = WireMockStubMapping.buildFrom(mappingDefinition)
- stubMapping.request.bodyPatterns.findAll { it.isPresent() && it instanceof RegexPattern }.every {
+ stubMapping
+ .request
+ .bodyPatterns
+ .findAll { it.isPresent() && it instanceof RegexPattern }.every {
Pattern.compile(it.getValue())
}
- assert !mappingDefinition.contains('org.springframework.cloud.contract.spec.internal')
+ assert !mappingDefinition
+ .contains('org.springframework.cloud.contract.spec.internal')
return stubMapping
}
@@ -1169,8 +1245,12 @@ class DslToWireMockClientConverterSpec extends Specification {
}
''')
when:
- String json = converter.convertContents("Test", new ContractMetadata(file.toPath(), false, 0, null,
- ContractVerifierDslConverter.convertAsCollection(new File("/"), file))).values().first()
+ String json =
+ converter.convertContents("Test", new ContractMetadata(
+ file.toPath(), false, 0, null,
+ ContractVerifierDslConverter
+ .convertAsCollection(new File("/"), file)))
+ .values().first()
then:
JSONAssert.assertEquals('''
{
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/build.gradle b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/build.gradle
index 5c6e67e50d..bd3bf17da1 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/build.gradle
+++ b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/build.gradle
@@ -1,3 +1,4 @@
+
buildscript {
repositories {
mavenCentral()
@@ -10,21 +11,6 @@ buildscript {
}
}
-// TODO: Remove me for Gradle 8.4 - https://github.com/gradle/gradle/issues/25434
-configurations {
- all {
- resolutionStrategy {
- eachDependency { dependency ->
- // Downgrade Spring Framework as Gradle cannot cope with 6.1.0-M1's
- // multi-version jar files with bytecode in META-INF/versions/21
- if (dependency.requested.group.equals("org.springframework")) {
- dependency.useVersion("6.0.10")
- }
- }
- }
- }
-}
-
ext {
repoUser = System.getenv('REPO_USERNAME') ?: project.findProperty('REPO_USERNAME') ?: ''
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/gradle.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/gradle.properties
index e2f0f20f2f..a54d800144 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/gradle.properties
+++ b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/gradle.properties
@@ -19,7 +19,7 @@ verifierVersion=5.0.0-SNAPSHOT
org.gradle.daemon=false
aetherVersion=1.1.0
springCloudBuildVersion=5.0.0-SNAPSHOT
-springVersion=6.0.10
+springVersion=7.0.0-SNAPSHOT
jacksonDatabindVersion=2.13.2.1
mavenResolverVersion=1.9.18
jgitVersion=5.12.0.202106070339-r
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/pom.xml b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/pom.xml
index 6c97dfbda7..c4f3d86723 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/pom.xml
+++ b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/pom.xml
@@ -341,11 +341,6 @@
test
-
- javax.inject
- javax.inject
- provided
-
org.apache.maven
maven-core
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/RunMojo.java b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/RunMojo.java
index db8a739062..bba41df7f5 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/RunMojo.java
+++ b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/RunMojo.java
@@ -20,8 +20,6 @@ import java.io.File;
import java.io.IOException;
import java.util.Collections;
-import javax.inject.Inject;
-
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -31,6 +29,7 @@ import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.eclipse.aether.RepositorySystemSession;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.maven.verifier.stubrunner.LocalStubRunner;
import org.springframework.cloud.contract.maven.verifier.stubrunner.RemoteStubRunner;
import org.springframework.cloud.contract.stubrunner.BatchStubRunner;
@@ -118,7 +117,7 @@ public class RunMojo extends AbstractMojo {
@Parameter(property = "spring.cloud.contract.verifier.server-id")
private String serverId;
- @Inject
+ @Autowired
public RunMojo(LocalStubRunner localStubRunner, RemoteStubRunner remoteStubRunner) {
this.localStubRunner = localStubRunner;
this.remoteStubRunner = remoteStubRunner;
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/AetherStubDownloaderFactory.java b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/AetherStubDownloaderFactory.java
index b548b18372..5cf9c5e986 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/AetherStubDownloaderFactory.java
+++ b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/AetherStubDownloaderFactory.java
@@ -16,10 +16,6 @@
package org.springframework.cloud.contract.maven.verifier.stubrunner;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.project.MavenProject;
@@ -27,12 +23,14 @@ import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import shaded.org.apache.maven.settings.Settings;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.stubrunner.AetherStubDownloader;
import org.springframework.cloud.contract.stubrunner.StubDownloader;
import org.springframework.cloud.contract.stubrunner.StubDownloaderBuilder;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
+import org.springframework.stereotype.Component;
/**
* Builds {@link StubDownloaderBuilder} for a Maven project.
@@ -40,8 +38,7 @@ import org.springframework.core.io.ResourceLoader;
* @author Mariusz Smykula
* @author EddĂș MelĂ©ndez
*/
-@Named
-@Singleton
+@Component
public class AetherStubDownloaderFactory {
private static final Log log = LogFactory.getLog(AetherStubDownloaderFactory.class);
@@ -52,7 +49,7 @@ public class AetherStubDownloaderFactory {
private final Settings settings;
- @Inject
+ @Autowired
public AetherStubDownloaderFactory(RepositorySystem repoSystem, MavenProject project, Settings settings) {
this.repoSystem = repoSystem;
this.project = project;
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/LocalStubRunner.java b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/LocalStubRunner.java
index fd09515534..55b626aa44 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/LocalStubRunner.java
+++ b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/LocalStubRunner.java
@@ -16,21 +16,20 @@
package org.springframework.cloud.contract.maven.verifier.stubrunner;
-import javax.inject.Named;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.contract.stubrunner.StubConfiguration;
import org.springframework.cloud.contract.stubrunner.StubRunner;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
+import org.springframework.stereotype.Component;
/**
* Allows running stubs from the given directory.
*
* @author Mariusz Smykula
*/
-@Named
+@Component
public class LocalStubRunner {
private static final Log log = LogFactory.getLog(LocalStubRunner.class);
diff --git a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/RemoteStubRunner.java b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/RemoteStubRunner.java
index fbeedcd86b..b780092545 100644
--- a/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/RemoteStubRunner.java
+++ b/spring-cloud-contract-tools/spring-cloud-contract-maven-plugin/src/main/java/org/springframework/cloud/contract/maven/verifier/stubrunner/RemoteStubRunner.java
@@ -16,32 +16,31 @@
package org.springframework.cloud.contract.maven.verifier.stubrunner;
-import javax.inject.Inject;
-import javax.inject.Named;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.aether.RepositorySystemSession;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.stubrunner.BatchStubRunner;
import org.springframework.cloud.contract.stubrunner.BatchStubRunnerFactory;
import org.springframework.cloud.contract.stubrunner.RunningStubs;
import org.springframework.cloud.contract.stubrunner.StubDownloader;
import org.springframework.cloud.contract.stubrunner.StubRunnerOptions;
+import org.springframework.stereotype.Component;
/**
* Fetches stubs from a remote location.
*
* @author Mariusz Smykula
*/
-@Named
+@Component
public class RemoteStubRunner {
private static final Log log = LogFactory.getLog(RemoteStubRunner.class);
private final AetherStubDownloaderFactory aetherStubDownloaderFactory;
- @Inject
+ @Autowired
public RemoteStubRunner(AetherStubDownloaderFactory aetherStubDownloaderFactory) {
this.aetherStubDownloaderFactory = aetherStubDownloaderFactory;
}
diff --git a/spring-cloud-contract-verifier/pom.xml b/spring-cloud-contract-verifier/pom.xml
index 917b9e163c..048ecac43a 100644
--- a/spring-cloud-contract-verifier/pom.xml
+++ b/spring-cloud-contract-verifier/pom.xml
@@ -110,10 +110,6 @@
spring-rabbit
true
-
- javax.inject
- javax.inject
-
com.github.tomakehurst
wiremock-jre8-standalone
@@ -126,6 +122,10 @@
org.apache.maven.resolver
maven-resolver-api
+
+ org.jspecify
+ jspecify
+
com.rackspace.eclipse.webtools.sourceediting
org.eclipse.wst.xml.xpath2.processor
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeFields.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeFields.java
index 685d0aeb2c..1c10c271ae 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeFields.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeFields.java
@@ -24,7 +24,7 @@ class CustomModeFields implements Field, CustomModeAcceptor {
private final GeneratedClassMetaData generatedClassMetaData;
- private static final String[] FIELDS = { "@Inject HttpVerifier httpVerifier" };
+ private static final String[] FIELDS = { "@Autowired HttpVerifier httpVerifier" };
CustomModeFields(BlockBuilder blockBuilder, GeneratedClassMetaData generatedClassMetaData) {
this.blockBuilder = blockBuilder;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeImports.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeImports.java
index 523d5da445..4051b9a8fe 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeImports.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/CustomModeImports.java
@@ -24,7 +24,7 @@ class CustomModeImports implements Imports, CustomModeAcceptor {
private final GeneratedClassMetaData generatedClassMetaData;
- private static final String[] IMPORTS = { "javax.inject.Inject",
+ private static final String[] IMPORTS = { "org.springframework.beans.factory.annotation.Autowired",
"org.springframework.cloud.contract.verifier.http.HttpVerifier",
"org.springframework.cloud.contract.verifier.http.Request",
"org.springframework.cloud.contract.verifier.http.Response;" };
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingFields.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingFields.java
index a7fcab1baa..642726b636 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingFields.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingFields.java
@@ -26,8 +26,8 @@ class MessagingFields implements Field {
private final GeneratedClassMetaData generatedClassMetaData;
- private static final String[] FIELDS = { "@Inject ContractVerifierMessaging contractVerifierMessaging",
- "@Inject ContractVerifierObjectMapper contractVerifierObjectMapper" };
+ private static final String[] FIELDS = { "@Autowired ContractVerifierMessaging contractVerifierMessaging",
+ "@Autowired ContractVerifierObjectMapper contractVerifierObjectMapper" };
MessagingFields(BlockBuilder blockBuilder, GeneratedClassMetaData generatedClassMetaData) {
this.blockBuilder = blockBuilder;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingImports.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingImports.java
index fae3d9654d..511593dd26 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingImports.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/builder/MessagingImports.java
@@ -26,7 +26,7 @@ class MessagingImports implements Imports {
private final GeneratedClassMetaData generatedClassMetaData;
- private static final String[] IMPORTS = { "javax.inject.Inject",
+ private static final String[] IMPORTS = { "org.springframework.beans.factory.annotation.Autowired",
"org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper",
"org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage",
"org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging" };
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/dsl/ContractVerifierMetadata.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/dsl/ContractVerifierMetadata.java
index a94fd46bfd..7374afd90f 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/dsl/ContractVerifierMetadata.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/dsl/ContractVerifierMetadata.java
@@ -18,9 +18,10 @@ package org.springframework.cloud.contract.verifier.dsl;
import java.util.Map;
+import org.jspecify.annotations.NonNull;
+
import org.springframework.cloud.contract.verifier.util.MetadataUtil;
import org.springframework.cloud.contract.verifier.util.SpringCloudContractMetadata;
-import org.springframework.lang.NonNull;
/**
* Metadata representation of the Contract Verifier.
@@ -52,8 +53,7 @@ public class ContractVerifierMetadata implements SpringCloudContractMetadata {
this.tool = tool;
}
- @NonNull
- public static ContractVerifierMetadata fromMetadata(Map metadata) {
+ public static @NonNull ContractVerifierMetadata fromMetadata(Map metadata) {
return MetadataUtil.fromMetadata(metadata, METADATA_KEY, new ContractVerifierMetadata());
}
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/http/ContractVerifierHttpMetaData.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/http/ContractVerifierHttpMetaData.java
index 1d245557a0..d0fff0b80b 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/http/ContractVerifierHttpMetaData.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/http/ContractVerifierHttpMetaData.java
@@ -19,10 +19,11 @@ package org.springframework.cloud.contract.verifier.http;
import java.util.Arrays;
import java.util.Map;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import org.springframework.cloud.contract.verifier.util.MetadataUtil;
import org.springframework.cloud.contract.verifier.util.SpringCloudContractMetadata;
-import org.springframework.lang.NonNull;
-import org.springframework.lang.Nullable;
/**
* Metadata representation of the Contract Verifier's HTTP communication.
@@ -49,8 +50,7 @@ public class ContractVerifierHttpMetaData implements SpringCloudContractMetadata
*/
private Protocol protocol = Protocol.HTTP_1_1;
- @NonNull
- public static ContractVerifierHttpMetaData fromMetadata(Map metadata) {
+ public static @NonNull ContractVerifierHttpMetaData fromMetadata(Map metadata) {
return MetadataUtil.fromMetadata(metadata, METADATA_KEY, new ContractVerifierHttpMetaData());
}
@@ -106,8 +106,7 @@ public class ContractVerifierHttpMetaData implements SpringCloudContractMetadata
/**
* Builds an enum from string.
*/
- @Nullable
- public static Scheme fromString(String scheme) {
+ public static @Nullable Scheme fromString(String scheme) {
return Arrays.stream(values()).filter(p -> p.name().equalsIgnoreCase(scheme)).findFirst().orElse(null);
}
@@ -179,8 +178,7 @@ public class ContractVerifierHttpMetaData implements SpringCloudContractMetadata
/**
* Builds an enum from string.
*/
- @Nullable
- public static Protocol fromString(String protocol) {
+ public static @Nullable Protocol fromString(String protocol) {
return Arrays.stream(values()).filter(p -> p.protocol.equalsIgnoreCase(protocol)).findFirst().orElse(null);
}
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierReceiver.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierReceiver.java
index b6c8af02cd..fa8c8a9088 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierReceiver.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierReceiver.java
@@ -18,7 +18,7 @@ package org.springframework.cloud.contract.verifier.messaging;
import java.util.concurrent.TimeUnit;
-import javax.annotation.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.cloud.contract.verifier.converter.YamlContract;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierSender.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierSender.java
index b93dccf4c6..850aeeae3d 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierSender.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/MessageVerifierSender.java
@@ -18,7 +18,7 @@ package org.springframework.cloud.contract.verifier.messaging;
import java.util.Map;
-import javax.annotation.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.cloud.contract.verifier.converter.YamlContract;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/camel/ContractVerifierCamelConfiguration.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/camel/ContractVerifierCamelConfiguration.java
index 52f1d629cc..3557bf925a 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/camel/ContractVerifierCamelConfiguration.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/camel/ContractVerifierCamelConfiguration.java
@@ -24,7 +24,7 @@ import org.apache.camel.ConsumerTemplate;
import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/integration/ContractVerifierIntegrationConfiguration.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/integration/ContractVerifierIntegrationConfiguration.java
index 88bd077f02..8fb9e68ad2 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/integration/ContractVerifierIntegrationConfiguration.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/integration/ContractVerifierIntegrationConfiguration.java
@@ -19,7 +19,7 @@ package org.springframework.cloud.contract.verifier.messaging.integration;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/internal/ContractVerifierMessaging.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/internal/ContractVerifierMessaging.java
index 886b1a3eda..bd2af7be5a 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/internal/ContractVerifierMessaging.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/internal/ContractVerifierMessaging.java
@@ -18,10 +18,9 @@ package org.springframework.cloud.contract.verifier.messaging.internal;
import java.util.Map;
-import javax.annotation.Nullable;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jspecify.annotations.Nullable;
import org.springframework.cloud.contract.verifier.converter.YamlContract;
import org.springframework.cloud.contract.verifier.messaging.MessageVerifierReceiver;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/jms/ContractVerifierJmsConfiguration.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/jms/ContractVerifierJmsConfiguration.java
index feb9b65f3b..ed7fd95472 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/jms/ContractVerifierJmsConfiguration.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/jms/ContractVerifierJmsConfiguration.java
@@ -28,7 +28,7 @@ import jakarta.jms.StreamMessage;
import jakarta.jms.TextMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/noop/NoOpContractVerifierAutoConfiguration.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/noop/NoOpContractVerifierAutoConfiguration.java
index 66547f79d7..179b603393 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/noop/NoOpContractVerifierAutoConfiguration.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/noop/NoOpContractVerifierAutoConfiguration.java
@@ -20,7 +20,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
diff --git a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/ContractVerifierStreamAutoConfiguration.java b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/ContractVerifierStreamAutoConfiguration.java
index 301436442a..56720e2cdc 100644
--- a/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/ContractVerifierStreamAutoConfiguration.java
+++ b/spring-cloud-contract-verifier/src/main/java/org/springframework/cloud/contract/verifier/messaging/stream/ContractVerifierStreamAutoConfiguration.java
@@ -19,7 +19,7 @@ package org.springframework.cloud.contract.verifier.messaging.stream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
diff --git a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/MessagingMethodBodyBuilderSpec.groovy b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/MessagingMethodBodyBuilderSpec.groovy
index 9260686b86..e574f4efe1 100644
--- a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/MessagingMethodBodyBuilderSpec.groovy
+++ b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/MessagingMethodBodyBuilderSpec.groovy
@@ -105,7 +105,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -118,8 +118,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -191,7 +191,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.Rule;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
@@ -204,8 +204,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
public class FooTest {
- @Inject ContractVerifierMessaging contractVerifierMessaging;
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper;
+ @Autowired ContractVerifierMessaging contractVerifierMessaging;
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper;
@Test
public void validate_foo() throws Exception {
@@ -269,7 +269,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.Rule;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
@@ -282,8 +282,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
public class FooTest {
- @Inject ContractVerifierMessaging contractVerifierMessaging;
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper;
+ @Autowired ContractVerifierMessaging contractVerifierMessaging;
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper;
@Test
public void validate_foo() throws Exception {
@@ -479,7 +479,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -492,8 +492,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -551,7 +551,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -564,8 +564,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -623,7 +623,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -636,8 +636,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -697,7 +697,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.Rule;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
@@ -710,8 +710,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
public class FooTest {
- @Inject ContractVerifierMessaging contractVerifierMessaging;
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper;
+ @Autowired ContractVerifierMessaging contractVerifierMessaging;
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper;
@Test
public void validate_foo() throws Exception {
@@ -776,7 +776,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -789,8 +789,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -819,7 +819,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.Rule;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
@@ -832,8 +832,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
public class FooTest {
- @Inject ContractVerifierMessaging contractVerifierMessaging;
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper;
+ @Autowired ContractVerifierMessaging contractVerifierMessaging;
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper;
@Test
public void validate_foo() throws Exception {
@@ -905,7 +905,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -918,8 +918,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -961,7 +961,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.Rule;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
@@ -974,8 +974,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
public class FooTest {
- @Inject ContractVerifierMessaging contractVerifierMessaging;
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper;
+ @Autowired ContractVerifierMessaging contractVerifierMessaging;
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper;
@Test
public void validate_foo() throws Exception {
@@ -1046,7 +1046,7 @@ package com.example
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import spock.lang.Specification
-import javax.inject.Inject
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
@@ -1059,8 +1059,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
class FooSpec extends Specification {
- @Inject ContractVerifierMessaging contractVerifierMessaging
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper
+ @Autowired ContractVerifierMessaging contractVerifierMessaging
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper
def validate_foo() throws Exception {
when:
@@ -1088,7 +1088,7 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.Rule;
-import javax.inject.Inject;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage;
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging;
@@ -1101,8 +1101,8 @@ import static org.springframework.cloud.contract.verifier.util.ContractVerifierU
@SuppressWarnings("rawtypes")
public class FooTest {
- @Inject ContractVerifierMessaging contractVerifierMessaging;
- @Inject ContractVerifierObjectMapper contractVerifierObjectMapper;
+ @Autowired ContractVerifierMessaging contractVerifierMessaging;
+ @Autowired ContractVerifierObjectMapper contractVerifierObjectMapper;
@Test
public void validate_foo() throws Exception {
diff --git a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGeneratorSpec.groovy b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGeneratorSpec.groovy
index 663faa2e57..7f228eca0a 100644
--- a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGeneratorSpec.groovy
+++ b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGeneratorSpec.groovy
@@ -357,7 +357,7 @@ class SingleTestGeneratorSpec extends Specification {
then:
classStrings.each { clazz.contains(it) }
- clazz.contains('@Inject ContractVerifierMessaging')
+ clazz.contains('@Autowired ContractVerifierMessaging')
and:
asserter(clazz)
diff --git a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/dsl/wiremock/WireMockGroovyDslSpec.groovy b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/dsl/wiremock/WireMockGroovyDslSpec.groovy
index 9a34ef7092..ddf38ae0cf 100755
--- a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/dsl/wiremock/WireMockGroovyDslSpec.groovy
+++ b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/dsl/wiremock/WireMockGroovyDslSpec.groovy
@@ -34,42 +34,44 @@ import org.springframework.cloud.contract.verifier.converter.YamlContractConvert
import org.springframework.cloud.contract.verifier.file.ContractMetadata
import org.springframework.cloud.contract.verifier.util.AssertionUtil
import org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter
+import org.springframework.cloud.test.TestSocketUtils
import org.springframework.http.RequestEntity
import org.springframework.http.ResponseEntity
-import org.springframework.cloud.test.TestSocketUtils
class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifier {
def 'should convert groovy dsl stub to wireMock stub for the client side'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url $(consumer(~/\/[0-9]{2}/), producer('/12'))
- }
- response {
- status OK()
- body(
- id: value(
- consumer('123'),
- producer(regex('[0-9]+'))
- ),
- surname: $(
- consumer('Kowalsky'),
- producer(regex('[a-zA-Z]+'))
- ),
- name: 'Jan',
- created: $(consumer('2014-02-02 12:23:43'),
- producer(execute('currentDate($it)')))
- )
- headers {
- header 'Content-Type': 'application/json'
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url $(consumer(~/\/[0-9]{2}/), producer('/12'))
+ }
+ response {
+ status OK()
+ body(
+ id: value(
+ consumer('123'),
+ producer(regex('[0-9]+'))
+ ),
+ surname: $(
+ consumer('Kowalsky'),
+ producer(regex('[a-zA-Z]+'))
+ ),
+ name: 'Jan',
+ created: $(consumer('2014-02-02 12:23:43'),
+ producer(execute('currentDate($it)')))
+ )
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ }
}
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -95,29 +97,31 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#79")
def 'should convert groovy dsl stub to wireMock stub for the client side with a body containing a map'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url '/ingredients'
- headers {
- header 'Content-Type': 'application/vnd.pl.devoxx.aggregatr.v1+json'
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url '/ingredients'
+ headers {
+ header 'Content-Type': 'application/vnd.pl.devoxx.aggregatr.v1+json'
+ }
+ }
+ response {
+ status OK()
+ body(
+ ingredients: [
+ [type: 'MALT', quantity: 100],
+ [type: 'WATER', quantity: 200],
+ [type: 'HOP', quantity: 300],
+ [type: 'YIEST', quantity: 400]
+ ]
+ )
+ }
}
- }
- response {
- status OK()
- body(
- ingredients: [
- [type: 'MALT', quantity: 100],
- [type: 'WATER', quantity: 200],
- [type: 'HOP', quantity: 300],
- [type: 'YIEST', quantity: 400]
- ]
- )
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -145,34 +149,36 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#86")
def 'should convert groovy dsl stub with GString and regexp'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('POST')
- url('/ws/payments')
- headers {
- header("Content-Type": 'application/x-www-form-urlencoded')
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('POST')
+ url('/ws/payments')
+ headers {
+ header("Content-Type": 'application/x-www-form-urlencoded')
+ }
+ body("""paymentType=INCOMING&transferType=BANK&amount=${
+ value(consumer(regex('[0-9]{3}\\.[0-9]{2}')),
+ producer(500.00))
+ }&bookingDate=${
+ value(consumer(
+ regex('[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])')),
+ producer('2015-05-18'))
+ }""")
+ }
+ response {
+ status 204
+ body(
+ paymentId: value(consumer('4'),
+ producer(regex('[1-9][0-9]*'))),
+ foundExistingPayment: false
+ )
+ }
}
- body("""paymentType=INCOMING&transferType=BANK&amount=${
- value(consumer(regex('[0-9]{3}\\.[0-9]{2}')),
- producer(500.00))
- }&bookingDate=${
- value(consumer(
- regex('[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])')),
- producer('2015-05-18'))
- }""")
- }
- response {
- status 204
- body(
- paymentId: value(consumer('4'),
- producer(regex('[1-9][0-9]*'))),
- foundExistingPayment: false
- )
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -204,35 +210,38 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should convert groovy dsl stub with Body as String to wireMock stub for the client side'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url $(consumer(~/\/[0-9]{2}/), producer('/12'))
- }
- response {
- status OK()
- body("""\
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url $(consumer(~/\/[0-9]{2}/), producer('/12'))
+ }
+ response {
+ status OK()
+ body("""\
{
"id": "${value(consumer('123'), producer('321'))}",
"surname": "${
- value(consumer('Kowalsky'), producer(regex('[a-zA-Z]+')))
- }",
+ value(consumer('Kowalsky'),
+ producer(regex('[a-zA-Z]+')))
+ }",
"name": "Jan",
"created" : "${
- $(consumer('2014-02-02 12:23:43'),
- producer('2999-09-09 01:23:45'))
- }"
+ $(consumer('2014-02-02 12:23:43'),
+ producer('2999-09-09 01:23:45'))
+ }"
}
"""
- )
- headers {
- header 'Content-Type': 'application/json'
+ )
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ }
}
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
def actual = new JsonSlurper().parseText(wireMockStub)
@@ -264,32 +273,34 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should convert groovy dsl stub with simple Body as String to wireMock stub for the client side'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url $(consumer(regex('/[0-9]{2}')), producer('/12'))
- body """
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url $(consumer(regex('/[0-9]{2}')), producer('/12'))
+ body """
{
"name": "Jan"
}
"""
- }
- response {
- status OK()
- body("""\
+ }
+ response {
+ status OK()
+ body("""\
{
"name": "Jan"
}
"""
- )
- headers {
- header 'Content-Type': 'application/json'
+ )
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ }
}
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -317,31 +328,33 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use equalToJson when body match is defined as map'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url $(consumer(~/\/[0-9]{2}/), producer('/12'))
- body(
- id: value(
- consumer(regex('[0-9]+')),
- producer('123'),
- ),
- surname: $(
- consumer(regex('[a-zA-Z]+')),
- producer('Kowalsky'),
- ),
- name: 'Jan',
- created: $(consumer('2014-02-02 12:23:43'),
- producer(execute('currentDate($it)')))
- )
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url $(consumer(~/\/[0-9]{2}/), producer('/12'))
+ body(
+ id: value(
+ consumer(regex('[0-9]+')),
+ producer('123'),
+ ),
+ surname: $(
+ consumer(regex('[a-zA-Z]+')),
+ producer('Kowalsky'),
+ ),
+ name: 'Jan',
+ created: $(consumer('2014-02-02 12:23:43'),
+ producer(execute('currentDate($it)')))
+ )
+ }
+ response {
+ status OK()
+ }
+ }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -371,24 +384,25 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use equalToJson when content type ends with json'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- headers {
- header "Content-Type", "customtype/json"
- }
- body """
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ headers {
+ header "Content-Type", "customtype/json"
+ }
+ body """
{
"name": "Jan"
}
"""
- }
- response {
- status OK()
- }
- }
+ }
+ response {
+ status OK()
+ }
+ }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -418,24 +432,26 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use xml matchers when content type ends with xml'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- headers {
- header "Content-Type", "customtype/xml"
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ headers {
+ header "Content-Type", "customtype/xml"
+ }
+ body """${
+ value(consumer('Jozo'), producer('Denis'))
+ }${
+ value(consumer("<test>"),
+ producer('1234567890'))
+ }"""
+ }
+ response {
+ status OK()
+ }
}
- body """${
- value(consumer('Jozo'), producer('Denis'))
- }${
- value(consumer("<test>"), producer('1234567890'))
- }"""
- }
- response {
- status OK()
- }
- }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -479,21 +495,23 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use xml matchers when content type is parsable xml'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- body """${
- value(consumer('Jozo'), producer('Denis'))
- }${
- value(consumer("<test>"), producer('1234567890'))
- }"""
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ body """${
+ value(consumer('Jozo'), producer('Denis'))
+ }${
+ value(consumer("<test>"),
+ producer('1234567890'))
+ }"""
+ }
+ response {
+ status OK()
+ }
+ }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -532,21 +550,22 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should support xml as a response body'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- }
- response {
- status OK()
- body """${
- value(consumer('Jozo'), producer('Denis'))
- }${
- value(consumer(""), producer('1234567890'))
- }"""
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ }
+ response {
+ status OK()
+ body """${
+ value(consumer('Jozo'), producer('Denis'))
+ }${
+ value(consumer(""), producer('1234567890'))
+ }"""
+ }
+ }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -569,17 +588,18 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use equalToJson'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- body equalToJson('''{"name":"Jan"}''')
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ body equalToJson('''{"name":"Jan"}''')
+ }
+ response {
+ status OK()
+ }
+ }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -606,23 +626,24 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use equalToJson and bodyMatchers with json content type'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- headers {
- header 'Content-Type': 'application/json'
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ body equalToJson('''{"name":"Jan"}''')
+ bodyMatchers {
+ jsonPath('$.name', byRegex('[A-Z]{3}'))
+ }
+ }
+ response {
+ status OK()
+ }
}
- body equalToJson('''{"name":"Jan"}''')
- bodyMatchers {
- jsonPath('$.name', byRegex('[A-Z]{3}'))
- }
- }
- response {
- status OK()
- }
- }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -652,21 +673,23 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use equalToXml'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- body equalToXml("""${
- value(consumer('Jozo'), producer('Denis'))
- }${
- value(consumer("<test>"), producer('1234567890'))
- }""")
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ body equalToXml("""${
+ value(consumer('Jozo'), producer('Denis'))
+ }${
+ value(consumer("<test>"),
+ producer('1234567890'))
+ }""")
+ }
+ response {
+ status OK()
+ }
+ }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -693,28 +716,29 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use equalToXml and bodyMatchers with xml content type'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url "/users"
- headers {
- header "Content-Type", "customtype/xml"
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url "/users"
+ headers {
+ header "Content-Type", "customtype/xml"
+ }
+ body equalToXml(
+ """${
+ value(consumer('Jozo'),
+ producer('Denis'))
+ }1234567890"""
+ )
+ bodyMatchers {
+ xPath('/foo/jobId/text()', byRegex('[0-9]{10}'))
+ }
+ }
+ response {
+ status OK()
+ }
}
- body equalToXml(
- """${
- value(consumer('Jozo'),
- producer('Denis'))
- }1234567890"""
- )
- bodyMatchers {
- xPath('/foo/jobId/text()', byRegex('[0-9]{10}'))
- }
- }
- response {
- status OK()
- }
- }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -744,20 +768,21 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should create stub with body from the file'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- headers {
- header 'Content-Type': 'application/xml'
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ headers {
+ header 'Content-Type': 'application/xml'
+ }
+ url "/users"
+ body file('classpath/request.xml')
+ }
+ response {
+ status OK()
+ }
}
- url "/users"
- body file('classpath/request.xml')
- }
- response {
- status OK()
- }
- }
when:
String json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -793,35 +818,37 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should convert groovy dsl stub with regexp Body as String to wireMock stub for the client side'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url $(consumer(regex('/[0-9]{2}')), producer('/12'))
- body """
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url $(consumer(regex('/[0-9]{2}')), producer('/12'))
+ body """
{
"personalId": "${
- value(consumer(regex('^[0-9]{11}$')),
- producer('57593728525'))
- }"
+ value(consumer(regex('^[0-9]{11}$')),
+ producer('57593728525'))
+ }"
}
"""
- }
- response {
- status OK()
- body("""\
+ }
+ response {
+ status OK()
+ body("""\
{
"name": "Jan"
}
"""
- )
- headers {
- header 'Content-Type': 'application/json'
+ )
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ }
}
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -849,41 +876,43 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should convert groovy dsl stub with a regexp and an integer in request body'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'PUT'
- url '/fraudcheck'
- body("""
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'PUT'
+ url '/fraudcheck'
+ body("""
{
"clientPesel":"${
- value(consumer(regex('[0-9]{10}')),
- producer('1234567890'))
- }",
+ value(consumer(regex('[0-9]{10}')),
+ producer('1234567890'))
+ }",
"loanAmount":123.123
}
"""
- )
- headers {
- header('Content-Type', 'application/vnd.fraud.v1+json')
- }
+ )
+ headers {
+ header('Content-Type', 'application/vnd.fraud.v1+json')
+ }
- }
- response {
- status OK()
- body(
- fraudCheckStatus: "OK",
- rejectionReason: $(consumer(null), producer(
- execute('assertThatRejectionReasonIsNull($it)')))
- )
- headers {
- header('Content-Type': 'application/vnd.fraud.v1+json')
- }
- }
+ }
+ response {
+ status OK()
+ body(
+ fraudCheckStatus: "OK",
+ rejectionReason: $(consumer(null), producer(
+ execute('assertThatRejectionReasonIsNull($it)')))
+ )
+ headers {
+ header('Content-Type': 'application/vnd.fraud.v1+json')
+ }
+ }
- }
+ }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -918,34 +947,40 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate request with urlPath and queryParameters for client side"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath($(consumer("users"), producer("items"))) {
- queryParameters {
- parameter 'limit':
- $(consumer(equalTo("20")), producer("10"))
- parameter 'offset':
- $(consumer(containing("10")), producer("10"))
- parameter 'filter': "email"
- parameter 'sort': $(consumer(~/^[0-9]{10}$/),
- producer("1234567890"))
- parameter 'search':
- $(consumer(notMatching(~/^\/[0-9]{2}$/)),
- producer("10"))
- parameter 'age': $(consumer(notMatching("^\\w*\$")),
- producer(10))
- parameter 'name': $(consumer(matching("Denis.*")),
- producer("Denis"))
- parameter 'credit': absent()
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath($(consumer("users"), producer("items"))) {
+ queryParameters {
+ parameter 'limit':
+ $(consumer(equalTo("20")),
+ producer("10"))
+ parameter 'offset':
+ $(consumer(containing("10")),
+ producer("10"))
+ parameter 'filter': "email"
+ parameter 'sort': $(consumer(~/^[0-9]{10}$/),
+ producer("1234567890"))
+ parameter 'search':
+ $(consumer(
+ notMatching(~/^\/[0-9]{2}$/)),
+ producer("10"))
+ parameter 'age':
+ $(consumer(notMatching("^\\w*\$")),
+ producer(10))
+ parameter 'name':
+ $(consumer(matching("Denis.*")),
+ producer("Denis"))
+ parameter 'credit': absent()
+ }
+ }
+ }
+ response {
+ status OK()
}
}
- }
- response {
- status OK()
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -994,19 +1029,20 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#353")
def "should generate request with absent header for client side"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath('/some/path/*')
- headers {
- header('''Authentication''', absent())
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath('/some/path/*')
+ headers {
+ header('''Authentication''', absent())
+ }
+ }
+ response {
+ status OK()
+ }
}
- }
- response {
- status OK()
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1035,24 +1071,26 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate request with urlPathPattern and queryParameters for client side\
when both contains regular expressions"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath($(
- consumer(regex("/users/[0-9]+")),
- producer("/users/1"))) {
- queryParameters {
- parameter 'search':
- $(consumer(notMatching(~/^\/[0-9]{2}$/)),
- producer("10"))
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath($(
+ consumer(regex("/users/[0-9]+")),
+ producer("/users/1"))) {
+ queryParameters {
+ parameter 'search':
+ $(consumer(
+ notMatching(~/^\/[0-9]{2}$/)),
+ producer("10"))
+ }
+ }
+ }
+ response {
+ status OK()
}
}
- }
- response {
- status OK()
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1080,16 +1118,17 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate request with urlPath for client side"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath $(consumer("boxes"), producer("items"))
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath $(consumer("boxes"), producer("items"))
+ }
+ response {
+ status OK()
+ }
+ }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1111,16 +1150,17 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate simple request with urlPath for client side"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath "boxes"
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath "boxes"
+ }
+ response {
+ status OK()
+ }
+ }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1158,7 +1198,9 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
then:
def e = thrown(IllegalStateException)
- e.message.contains "Query parameter 'age' can't be of a matching type: NOT_MATCHING for the server side"
+ e
+ .message
+ .contains "Query parameter 'age' can't be of a matching type: NOT_MATCHING for the server side"
}
def "should not allow regexp in query parameter for server value"() {
@@ -1199,7 +1241,9 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
then:
def e = thrown(IllegalStateException)
- e.message.contains "Query parameter 'age' can't be of a matching type: NOT_MATCHING for the server side"
+ e
+ .message
+ .contains "Query parameter 'age' can't be of a matching type: NOT_MATCHING for the server side"
}
def "should not allow query parameter with a different absent variation for server/client"() {
@@ -1255,24 +1299,27 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate request with url and queryParameters for client side"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- url($(consumer(regex(/users\/[0-9]*/)),
- producer("users/123"))) {
- queryParameters {
- parameter 'age': $(consumer(notMatching("^\\w*\$")),
- producer(10))
- parameter 'name': $(consumer(matching("Denis.*")),
- producer("Denis"))
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ url($(consumer(regex(/users\/[0-9]*/)),
+ producer("users/123"))) {
+ queryParameters {
+ parameter 'age':
+ $(consumer(notMatching("^\\w*\$")),
+ producer(10))
+ parameter 'name':
+ $(consumer(matching("Denis.*")),
+ producer("Denis"))
+ }
+ }
+ }
+ response {
+ status OK()
}
}
- }
- response {
- status OK()
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1302,55 +1349,58 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should convert groovy dsl stub with rich tree Body as String to wireMock stub for the client side'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url $(consumer(~/\/[0-9]{2}/), producer('/12'))
- body """\
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url $(consumer(~/\/[0-9]{2}/), producer('/12'))
+ body """\
{
"personalId": "${
- value(consumer(regex('[0-9]{11}')),
- producer('57593728525'))
- }",
+ value(consumer(regex('[0-9]{11}')),
+ producer('57593728525'))
+ }",
"firstName": "${value(consumer(regex('.*')), producer('Bruce'))}",
"lastName": "${value(consumer(regex('.*')), producer('Lee'))}",
"birthDate": "${
- value(consumer(regex('[0-9]{4}-[0-9]{2}-[0-9]{2}')),
- producer('1985-12-12'))
- }",
+ value(consumer(
+ regex('[0-9]{4}-[0-9]{2}-[0-9]{2}')),
+ producer('1985-12-12'))
+ }",
"errors": [
{
"propertyName": "${
- value(consumer(regex('[0-9]{2}')), producer('04'))
- }",
+ value(consumer(regex('[0-9]{2}')), producer('04'))
+ }",
"providerValue": "Test"
},
{
"propertyName": "${
- value(consumer(regex('[0-9]{2}')), producer('08'))
- }",
+ value(consumer(regex('[0-9]{2}')), producer('08'))
+ }",
"providerValue": "Test"
}
]
}
"""
- }
- response {
- status OK()
- body("""\
+ }
+ response {
+ status OK()
+ body("""\
{
"name": "Jan"
}
"""
- )
- headers {
- header 'Content-Type': 'application/json'
+ )
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ }
}
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -1386,36 +1436,37 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should use regexp matches when request body match is defined using a map with a pattern'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'POST'
- url '/reissue-payment-order'
- body(
- loanNumber: "999997001",
- amount: value(
- consumer(regex('[0-9.]+')),
- producer('100.00')),
- currency: "DKK",
- applicationName: value(consumer(regex('.*')),
- producer("Auto-Repayments")),
- username: value(consumer(regex('.*')),
- producer("scheduler")),
- cardId: 1
- )
- }
- response {
- status OK()
- body '''
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'POST'
+ url '/reissue-payment-order'
+ body(
+ loanNumber: "999997001",
+ amount: value(
+ consumer(regex('[0-9.]+')),
+ producer('100.00')),
+ currency: "DKK",
+ applicationName: value(consumer(regex('.*')),
+ producer("Auto-Repayments")),
+ username: value(consumer(regex('.*')),
+ producer("scheduler")),
+ cardId: 1
+ )
+ }
+ response {
+ status OK()
+ body '''
{
"status": "OK"
}
'''
- headers {
- header 'Content-Type': 'application/json'
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ }
}
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1452,17 +1503,18 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate stub for empty body"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('POST')
- url("test")
- body("")
- }
- response {
- status 406
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('POST')
+ url("test")
+ body("")
+ }
+ response {
+ status 406
+ }
+ }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1487,17 +1539,18 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def "should generate stub with priority"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- priority 9
- request {
- method('POST')
- url("test")
- }
- response {
- status 406
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ priority 9
+ request {
+ method('POST')
+ url("test")
+ }
+ response {
+ status 406
+ }
+ }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1519,21 +1572,24 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#127")
def 'should use "test" as an alias for "server"'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('POST')
- url("foo")
- body(
- property: value(consumer("value"), producer("value"))
- )
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('POST')
+ url("foo")
+ body(
+ property: value(consumer("value"),
+ producer("value"))
+ )
+ }
+ response {
+ status OK()
+ }
+ }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -1557,21 +1613,23 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#121")
def 'should generate stub with empty list as a value of a field'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('POST')
- url("foo")
- body(
- values: []
- )
- }
- response {
- status OK()
- }
- }
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('POST')
+ url("foo")
+ body(
+ values: []
+ )
+ }
+ response {
+ status OK()
+ }
+ }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -1596,36 +1654,38 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should generate stub properly resolving GString with regular expression'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- priority 1
- request {
- method 'POST'
- url '/users/password'
- headers {
- header 'Content-Type': 'application/json'
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ priority 1
+ request {
+ method 'POST'
+ url '/users/password'
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ body(
+ email: $(
+ consumer(regex(email())),
+ producer('not.existing@user.com')),
+ callback_url: $(consumer(regex(hostname())),
+ producer('https://partners.com'))
+ )
+ }
+ response {
+ status 404
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ body(
+ code: 4,
+ message: "User not found by email = [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"
+ )
+ }
}
- body(
- email: $(
- consumer(regex(email())),
- producer('not.existing@user.com')),
- callback_url: $(consumer(regex(hostname())),
- producer('https://partners.com'))
- )
- }
- response {
- status 404
- headers {
- header 'Content-Type': 'application/json'
- }
- body(
- code: 4,
- message: "User not found by email = [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"
- )
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -1661,25 +1721,27 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should generate stub properly resolving GString with regular expression in url'() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
- request {
- method 'PUT'
- url "/partners/${value(consumer(regex('^[0-9]*$')), producer('11'))}/agents/11/customers/09665703Z"
- headers {
- header 'Content-Type': 'application/json'
+ request {
+ method 'PUT'
+ url "/partners/${value(consumer(regex('^[0-9]*$')), producer('11'))}/agents/11/customers/09665703Z"
+ headers {
+ header 'Content-Type': 'application/json'
+ }
+ body(
+ first_name: 'Josef',
+ )
+ }
+ response {
+ status 422
+ }
}
- body(
- first_name: 'Josef',
- )
- }
- response {
- status 422
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -1709,7 +1771,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue('42')
def 'should generate stub without optional parameters'() {
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, contractDsl), contractDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ contractDsl), contractDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual(('''
@@ -1825,7 +1888,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
String toWireMockClientJsonStub(Contract groovyDsl) {
- return new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ return new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
}
@@ -1833,37 +1897,39 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
def 'should generate stub with multipart parameters'() {
given:
// tag::multipartdsl[]
- org.springframework.cloud.contract.spec.Contract contractDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method "PUT"
- url "/multipart"
- headers {
- contentType('multipart/form-data;boundary=AaB03x')
+ org.springframework.cloud.contract.spec.Contract contractDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method "PUT"
+ url "/multipart"
+ headers {
+ contentType('multipart/form-data;boundary=AaB03x')
+ }
+ multipart(
+ // key (parameter name), value (parameter value) pair
+ formParameter: $(c(regex('".+"')),
+ p('"formParameterValue"')),
+ someBooleanParameter:
+ $(c(regex(anyBoolean())), p('true')),
+ // a parameter name (e.g. file)
+ file: named(
+ // name of the file
+ name: $(c(regex(nonEmpty())),
+ p('filename.csv')),
+ // content of the file
+ content: $(c(regex(nonEmpty())),
+ p('file content')))
+ )
+ }
+ response {
+ status OK()
+ }
}
- multipart(
- // key (parameter name), value (parameter value) pair
- formParameter: $(c(regex('".+"')),
- p('"formParameterValue"')),
- someBooleanParameter:
- $(c(regex(anyBoolean())), p('true')),
- // a parameter name (e.g. file)
- file: named(
- // name of the file
- name: $(c(regex(nonEmpty())),
- p('filename.csv')),
- // content of the file
- content: $(c(regex(nonEmpty())),
- p('file content')))
- )
- }
- response {
- status OK()
- }
- }
// end::multipartdsl[]
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, contractDsl), contractDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ contractDsl), contractDsl).
toWireMockClientStub()
then:
println wireMockStub
@@ -1902,52 +1968,53 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue('#219')
def "should generate request with an optional queryParameter for client side"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath('/some/api') {
- queryParameters {
- parameter 'size': value(
- consumer(regex('[0-9]+')),
- producer(1)
- )
- parameter 'page': value(
- consumer(regex('[0-9]+')),
- producer(0)
- )
- parameter sort: value(
- consumer(optional(regex('^[a-z]+$'))),
- producer('id')
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath('/some/api') {
+ queryParameters {
+ parameter 'size': value(
+ consumer(regex('[0-9]+')),
+ producer(1)
+ )
+ parameter 'page': value(
+ consumer(regex('[0-9]+')),
+ producer(0)
+ )
+ parameter sort: value(
+ consumer(optional(regex('^[a-z]+$'))),
+ producer('id')
+ )
+ }
+ }
+ }
+ response {
+ status OK()
+ body(
+ content: [[
+ id : '00000000-0000-0000-0000-000000000000',
+ type : 'Extraordinary',
+ state: 'ACTIVE',
+ ]],
+ totalPages: 1,
+ totalElements: 1,
+ last: true,
+ sort: [[
+ direction : 'ASC',
+ property : 'id',
+ ignoreCase : false,
+ nullHandling: 'NATIVE',
+ ascending : true
+ ]],
+ first: true,
+ numberOfElements: 1,
+ size: 1,
+ number: 0
)
}
}
- }
- response {
- status OK()
- body(
- content: [[
- id : '00000000-0000-0000-0000-000000000000',
- type : 'Extraordinary',
- state: 'ACTIVE',
- ]],
- totalPages: 1,
- totalElements: 1,
- last: true,
- sort: [[
- direction : 'ASC',
- property : 'id',
- ignoreCase : false,
- nullHandling: 'NATIVE',
- ascending : true
- ]],
- first: true,
- numberOfElements: 1,
- size: 1,
- number: 0
- )
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -1982,25 +2049,26 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue('#30')
def "should not create a stub for a skipped contract"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- ignored()
- method 'GET'
- urlPath('/some/api') {
- queryParameters {
- parameter 'size': value(
- consumer(regex('[0-9]+')),
- producer(1)
- )
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ ignored()
+ method 'GET'
+ urlPath('/some/api') {
+ queryParameters {
+ parameter 'size': value(
+ consumer(regex('[0-9]+')),
+ producer(1)
+ )
+ }
+ }
+ }
+ response {
+ status OK()
+ body('')
}
}
- }
- response {
- status OK()
- body('')
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -2010,26 +2078,28 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue('#30')
def "should not create a stub for a contract matching ignored pattern"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'GET'
- urlPath('/some/api') {
- queryParameters {
- parameter 'size': value(
- consumer(regex('[0-9]+')),
- producer(1)
- )
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'GET'
+ urlPath('/some/api') {
+ queryParameters {
+ parameter 'size': value(
+ consumer(regex('[0-9]+')),
+ producer(1)
+ )
+ }
+ }
+ }
+ response {
+ status OK()
+ body('')
}
}
- }
- response {
- status OK()
- body('')
- }
- }
when:
- def json = new WireMockStubStrategy("Test", new ContractMetadata(null, true, 0, null, groovyDsl), groovyDsl).
+ def json = new WireMockStubStrategy("Test", new ContractMetadata(null, true, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
json == null
@@ -2083,8 +2153,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
when:
ResponseEntity entity = call(port)
then:
- entity.headers.
- find { it.key == "authorization" && it.value.contains("secret;foo") }
+ entity.headers.toSingleValueMap()
+ .find { it.key == "authorization" && it.value.contains("secret;foo") }
AssertionUtil.assertThatJsonsAreEqual(('''
{
"url" : "/api/v1/xxxx?foo=bar&foo=bar2",
@@ -2126,7 +2196,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
when:
ResponseEntity entity = callBytes(port, request)
then:
- entity.statusCodeValue == 200
+ entity.statusCode.value() == 200
entity.body == response.bytes
cleanup:
server?.shutdown()
@@ -2135,58 +2205,66 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue('#540')
def "should generate a stub with standard WireMock request template"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method 'POST'
- url('/api/v1/xxxx') {
- queryParameters {
- parameter("foo", "bar")
- parameter("foo", "bar2")
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method 'POST'
+ url('/api/v1/xxxx') {
+ queryParameters {
+ parameter("foo", "bar")
+ parameter("foo", "bar2")
+ }
+ }
+ headers {
+ header(authorization(), "secret")
+ header(authorization(), "secret2")
+ }
+ cookies {
+ cookie("foo", "bar")
+ }
+ body(foo: "bar", baz: 5)
+ }
+ response {
+ status OK()
+ headers {
+ header(authorization(), "${fromRequest().header(authorization())};foo")
+ }
+ body(
+ url: fromRequest().url(),
+ path: fromRequest().path(),
+ pathIndex: fromRequest().path(1),
+ param: fromRequest().query("foo"),
+ paramIndex: fromRequest().query("foo", 1),
+ authorization:
+ fromRequest().header("Authorization"),
+ authorization2:
+ fromRequest()
+ .header("Authorization", 1),
+ fullBody: fromRequest().body(),
+ responseFoo: fromRequest().body('$.foo'),
+ responseBaz: fromRequest().body('$.baz'),
+ responseBaz2: "Bla bla ${fromRequest().body('$.foo')} bla bla",
+ rawUrl: fromRequest().rawUrl(),
+ rawPath: fromRequest().rawPath(),
+ rawPathIndex: fromRequest().rawPath(1),
+ rawParam: fromRequest().rawQuery("foo"),
+ rawParamIndex:
+ fromRequest().rawQuery("foo", 1),
+ rawAuthorization:
+ fromRequest()
+ .rawHeader("Authorization"),
+ rawAuthorization2:
+ fromRequest()
+ .rawHeader("Authorization", 1),
+ rawResponseFoo:
+ fromRequest().rawBody('$.foo'),
+ rawResponseBaz:
+ fromRequest().rawBody('$.baz'),
+ rawResponseBaz2: "Bla bla ${fromRequest().rawBody('$.foo')} bla bla"
+ )
}
}
- headers {
- header(authorization(), "secret")
- header(authorization(), "secret2")
- }
- cookies {
- cookie("foo", "bar")
- }
- body(foo: "bar", baz: 5)
- }
- response {
- status OK()
- headers {
- header(authorization(), "${fromRequest().header(authorization())};foo")
- }
- body(
- url: fromRequest().url(),
- path: fromRequest().path(),
- pathIndex: fromRequest().path(1),
- param: fromRequest().query("foo"),
- paramIndex: fromRequest().query("foo", 1),
- authorization: fromRequest().header("Authorization"),
- authorization2:
- fromRequest().header("Authorization", 1),
- fullBody: fromRequest().body(),
- responseFoo: fromRequest().body('$.foo'),
- responseBaz: fromRequest().body('$.baz'),
- responseBaz2: "Bla bla ${fromRequest().body('$.foo')} bla bla",
- rawUrl: fromRequest().rawUrl(),
- rawPath: fromRequest().rawPath(),
- rawPathIndex: fromRequest().rawPath(1),
- rawParam: fromRequest().rawQuery("foo"),
- rawParamIndex: fromRequest().rawQuery("foo", 1),
- rawAuthorization:
- fromRequest().rawHeader("Authorization"),
- rawAuthorization2:
- fromRequest().rawHeader("Authorization", 1),
- rawResponseFoo: fromRequest().rawBody('$.foo'),
- rawResponseBaz: fromRequest().rawBody('$.baz'),
- rawResponseBaz2: "Bla bla ${fromRequest().rawBody('$.foo')} bla bla"
- )
- }
- }
when:
def json = toWireMockClientJsonStub(groovyDsl)
then:
@@ -2235,8 +2313,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
server.addStubMapping(WireMockStubMapping.buildFrom(json))
then:
ResponseEntity entity = call(port)
- entity.headers.
- find { it.key == "authorization" && it.value.contains("secret;foo") }
+ entity.headers.toSingleValueMap()
+ .find { it.key == "authorization" && it.value.contains("secret;foo") }
and:
AssertionUtil.assertThatJsonsAreEqual(('''
{
@@ -2431,7 +2509,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -2496,7 +2575,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -2551,7 +2631,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -2616,7 +2697,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
!wireMockStub.contains("&")
@@ -2678,7 +2760,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -2719,7 +2802,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
}
}
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -2798,10 +2882,12 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#94")
def "should not produce any cursors in the stub"() {
given:
- Contract contractDsl = Contract.make {
+ Contract contractDsl = Contract.make {
request {
method 'POST'
- urlPath $(test('/resource/resourceId/another-resource/another-resource-id/sth'), stub(regex('/resource/[\\w\\.]+/another-resource/([\\w+\\.-]|%[a-fA-F0-9]{2})+/sth')))
+ urlPath $(
+ test('/resource/resourceId/another-resource/another-resource-id/sth'),
+ stub(regex('/resource/[\\w\\.]+/another-resource/([\\w+\\.-]|%[a-fA-F0-9]{2})+/sth')))
body($(stub(regex(".+")), test(execute("encrypt('a lot of code')"))))
}
response {
@@ -2823,11 +2909,11 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#894")
def "should not fail when matchers don't have dots"() {
given:
- Contract contractDsl = Contract.make {
+ Contract contractDsl = Contract.make {
request {
method 'POST'
url "/example"
- body([ "123", "234"])
+ body(["123", "234"])
bodyMatchers {
jsonPath('$[*]', byRegex(nonEmpty()))
}
@@ -2851,7 +2937,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
given:
File file = new File(WireMockGroovyDslSpec.getResource("/yml/issue1038.yml").
toURI())
- Contract contractDsl = new YamlContractConverter().convertFrom(file).first()
+ Contract contractDsl = new YamlContractConverter().convertFrom(file).first()
when:
String wireMockStub = new WireMockStubStrategy("Test",
new ContractMetadata(null, false, 0, null, contractDsl), contractDsl)
@@ -2876,7 +2962,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
contentType(applicationJson())
}
body(
- $(c([id: 4, foo:5, whatever:"hello"]), p(execute('hashCode()')))
+ $(c([id: 4, foo: 5, whatever: "hello"]),
+ p(execute('hashCode()')))
)
}
response {
@@ -2885,7 +2972,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
contentType(applicationJson())
}
body(
- $(c([id: 4, foo:5, whatever:"hello"]), p(execute('hashCode()')))
+ $(c([id: 4, foo: 5, whatever: "hello"]),
+ p(execute('hashCode()')))
)
}
}
@@ -2898,7 +2986,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
wireMockStub.contains('''$[?(@.['whatever'] == 'hello')]''')
wireMockStub.contains('''$[?(@.['id'] == 4)]''')
wireMockStub.contains('''$[?(@.['foo'] == 5)]''')
- wireMockStub.contains('''"{\\"id\\":4,\\"foo\\":5,\\"whatever\\":\\"hello\\"}"''')
+ wireMockStub
+ .contains('''"{\\"id\\":4,\\"foo\\":5,\\"whatever\\":\\"hello\\"}"''')
stubMappingIsValidWireMockStub(wireMockStub)
}
@@ -2908,7 +2997,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
given:
Contract contractDsl = Contract.make {
description "should return all entities"
- request{
+ request {
method GET()
url("/api/v1/entities")
}
@@ -2956,7 +3045,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
when:
ResponseEntity entity = callForStream(port)
then:
- entity.statusCodeValue == 200
+ entity.statusCode.value() == 200
entity.body.contains("Entity1")
entity.body.contains("Entity2")
cleanup:
@@ -2974,7 +3063,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
channedlId: "UC",
operations: [
[
- parameters : [
+ parameters: [
[
name : "#POID",
value: '70000269814',
@@ -2996,7 +3085,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
)
bodyMatchers {
jsonPath('$.operations[0].parameters[0].name', byEquality())
- jsonPath('$.operations[0].parameters[0].value', byRegex('[0-9]{11}'))
+ jsonPath('$.operations[0].parameters[0].value',
+ byRegex('[0-9]{11}'))
jsonPath('$.operations[0].parameters[0].type', byEquality())
jsonPath('$.operations[0].parameters[1].name', byEquality())
jsonPath('$.operations[0].parameters[1].value', byEquality())
@@ -3024,15 +3114,17 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("#1257")
def "should work with null request element on the client side and optional stub entry"() {
given:
- Contract contractDsl = Contract.make {
+ Contract contractDsl = Contract.make {
description("Creating user")
name("Create user")
request {
method 'POST'
url '/api/user'
body(
- address: $(consumer(optional(regex(alphaNumeric()))), producer(null)),
- name: $(consumer(optional(regex(alphaNumeric()))), producer(''))
+ address: $(consumer(optional(regex(alphaNumeric()))),
+ producer(null)),
+ name: $(consumer(optional(regex(alphaNumeric()))),
+ producer(''))
)
headers {
contentType(applicationJson())
@@ -3057,38 +3149,43 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
when:
ResponseEntity entity = callWithOptionalAndEmpty(port)
then:
- entity.statusCodeValue == 201
+ entity.statusCode.value() == 201
cleanup:
server?.shutdown()
}
def "should work with client DSL properties"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url("/api/foo")
- headers {
- header("foo", $(client(anyAlphaNumeric()), server("123")))
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url("/api/foo")
+ headers {
+ header("foo", $(client(anyAlphaNumeric()),
+ server("123")))
+ }
+ cookies {
+ cookie("cookie1", $(client("foo"), server("bar")))
+ cookie("cookie2",
+ $(client(~/[a-z]+/), server("bar")))
+ cookie("cookie3", $(client(anyAlphaNumeric()),
+ server("bar")))
+ cookie("cookie4", $(anyAlphaNumeric()))
+ }
+ }
+ response {
+ status OK()
+ body("ok")
+ headers {
+ header 'Content-Type': 'text/plain'
+ }
+ }
}
- cookies {
- cookie("cookie1", $(client("foo"), server("bar")))
- cookie("cookie2", $(client(~/[a-z]+/), server("bar")))
- cookie("cookie3", $(client(anyAlphaNumeric()), server("bar")))
- cookie("cookie4", $(anyAlphaNumeric()))
- }
- }
- response {
- status OK()
- body("ok")
- headers {
- header 'Content-Type': 'text/plain'
- }
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -3133,32 +3230,37 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
@Issue("1808")
def "should correctly process optional of DslProperty parameters"() {
given:
- org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
- make {
- request {
- method('GET')
- url("/api/foo")
- headers {
- header("Content-Type", "application/json")
- header("Accept", "application/json")
+ org.springframework.cloud.contract.spec.Contract groovyDsl =
+ org.springframework.cloud.contract.spec.Contract.
+ make {
+ request {
+ method('GET')
+ url("/api/foo")
+ headers {
+ header("Content-Type", "application/json")
+ header("Accept", "application/json")
+ }
+ body(
+ key1: $(client(optional(anyOf("foo", "bar"))),
+ server("bar")),
+ key2: $(client(optional(anyNonBlankString())),
+ server("bar")),
+ key3: $(client(optional(anyEmail())),
+ server("foo@bar.com")),
+ key4: $(optional(anyNumber())),
+ )
+ }
+ response {
+ status OK()
+ body("ok")
+ headers {
+ header 'Content-Type': 'text/plain'
+ }
+ }
}
- body(
- key1: $(client(optional(anyOf("foo", "bar"))), server("bar")),
- key2: $(client(optional(anyNonBlankString())), server("bar")),
- key3: $(client(optional(anyEmail())), server("foo@bar.com")),
- key4: $(optional(anyNumber())),
- )
- }
- response {
- status OK()
- body("ok")
- headers {
- header 'Content-Type': 'text/plain'
- }
- }
- }
when:
- String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
+ String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null,
+ groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
@@ -3211,7 +3313,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
ResponseEntity call(int port) {
return new TestRestTemplate().exchange(
RequestEntity.post(URI.
- create("http://localhost:" + port + "/api/v1/xxxx?foo=bar&foo=bar2"))
+ create("http://localhost:" +
+ port + "/api/v1/xxxx?foo=bar&foo=bar2"))
.header("Authorization", "secret")
.header("Authorization", "secret2")
.header("Cookie", "foo=bar")
@@ -3227,8 +3330,10 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
ResponseEntity callForStream(int port) {
return new TestRestTemplate().exchange(
- RequestEntity.get(URI.create("http://localhost:" + port + "/api/v1/entities"))
- .header("Content-Type", "application/stream+json").build(), String.class)
+ RequestEntity
+ .get(URI.create("http://localhost:" + port + "/api/v1/entities"))
+ .header("Content-Type", "application/stream+json").build(),
+ String.class)
}
ResponseEntity callBytes(int port, File request) {
@@ -3242,8 +3347,9 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
return new TestRestTemplate().exchange(
RequestEntity.
post(URI.create("http://localhost:" + port + "/api/categories"))
- .header("Content-Type", "application/json;charset=UTF-8")
- .body(JsonOutput.
- toJson([["Programming", "Java"], ["Programming", "Java", "Spring", "Boot"]])), String.class)
+ .header("Content-Type", "application/json;charset=UTF-8")
+ .body(JsonOutput.
+ toJson([["Programming", "Java"], ["Programming", "Java", "Spring", "Boot"]])),
+ String.class)
}
}
diff --git a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/util/SyntaxChecker.groovy b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/util/SyntaxChecker.groovy
index 67ccb7cba8..65c7dbe7b6 100644
--- a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/util/SyntaxChecker.groovy
+++ b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/util/SyntaxChecker.groovy
@@ -18,7 +18,6 @@ package org.springframework.cloud.contract.verifier.util
import java.lang.reflect.Method
-import javax.inject.Inject
import javax.tools.Diagnostic
import javax.tools.DiagnosticCollector
import javax.tools.FileObject
@@ -48,6 +47,7 @@ import org.junit.Test
import org.w3c.dom.Document
import org.xml.sax.InputSource
+import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
@@ -72,7 +72,7 @@ class SyntaxChecker {
Rule.name,
DocumentContext.name,
JsonPath.name,
- Inject.name,
+ Autowired.name,
ContractVerifierObjectMapper.name,
ContractVerifierMessage.name,
ContractVerifierMessaging.name,
diff --git a/spring-cloud-contract-wiremock/src/test/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippetTests.java b/spring-cloud-contract-wiremock/src/test/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippetTests.java
index 6a98c4246a..afe70459c3 100644
--- a/spring-cloud-contract-wiremock/src/test/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippetTests.java
+++ b/spring-cloud-contract-wiremock/src/test/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippetTests.java
@@ -25,6 +25,7 @@ import java.util.Set;
import org.apache.groovy.util.Maps;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -60,6 +61,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
// FIXME: 5.0.0 restdocs dropped junit 4
// @RunWith(SpringRunner.class)
// @SpringBootTest(classes = ContractDslSnippetTests.Config.class)
+// JUnit4 support will be removed with 5.0.0
+@Ignore
public class ContractDslSnippetTests {
private static final String OUTPUT = "target/generated-snippets";
diff --git a/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy b/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy
index 30b4a3a653..0d7f232b02 100644
--- a/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy
+++ b/tests/samples-messaging-amqp/src/test/groovy/com/example/AmqpMessagingApplicationSpec.groovy
@@ -16,12 +16,10 @@
package com.example
-import javax.inject.Inject
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import com.toomuchcoding.jsonassert.JsonAssertion
-import groovy.json.JsonOutput
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
@@ -29,14 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.cloud.contract.spec.Contract
import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier
-import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessage
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
-import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson
-import static org.assertj.core.api.Assertions.assertThat
-import static org.springframework.cloud.contract.verifier.messaging.util.ContractVerifierMessagingUtil.headers
-
// Context configuration would end up in base class
@AutoConfigureMessageVerifier
@SpringBootTest(classes = AmqpMessagingApplication, properties = "stubrunner.amqp.enabled=true")
@@ -44,47 +37,47 @@ import static org.springframework.cloud.contract.verifier.messaging.util.Contrac
class AmqpMessagingApplicationSpec {
// ALL CASES
- @Inject
+ @Autowired
ContractVerifierMessaging contractVerifierMessaging
- @Inject
+ @Autowired
ContractVerifierObjectMapper contractVerifierObjectMapper
@Test
void should_work_for_triggered_based_messaging() {
// given:
- def dsl = Contract.make {
- // Human readable description
- description 'Some description'
- // Label by means of which the output message can be triggered
- label 'some_label'
- // input to the contract
- input {
- // the contract will be triggered by a method
- triggeredBy('publishBook()')
- }
- // output message of the contract
- outputMessage {
- // destination to which the output message will be sent
- sentTo('test-exchange')
- // the body of the output message
- body('''{ "name" : "some" }''')
- // the headers of the output message
- headers {
- header('contentType', 'application/json')
- header('__TypeId__', 'com.example.Book')
- }
+ def dsl = Contract.make {
+ // Human readable description
+ description 'Some description'
+ // Label by means of which the output message can be triggered
+ label 'some_label'
+ // input to the contract
+ input {
+ // the contract will be triggered by a method
+ triggeredBy('publishBook()')
+ }
+ // output message of the contract
+ outputMessage {
+ // destination to which the output message will be sent
+ sentTo('test-exchange')
+ // the body of the output message
+ body('''{ "name" : "some" }''')
+ // the headers of the output message
+ headers {
+ header('contentType', 'application/json')
+ header('__TypeId__', 'com.example.Book')
}
}
- // generated test should look like this:
+ }
+ // generated test should look like this:
// when:
- publishBook()
+ publishBook()
// then:
- def response = contractVerifierMessaging.receive('test-exchange')
- response.headers.get('contentType') == 'application/json'
+ def response = contractVerifierMessaging.receive('test-exchange')
+ response.headers.get('contentType') == 'application/json'
// and:
- DocumentContext parsedJson = JsonPath.
- parse(contractVerifierObjectMapper.writeValueAsString(response.payload))
- JsonAssertion.assertThat(parsedJson).field('name').isEqualTo('some')
+ DocumentContext parsedJson = JsonPath.
+ parse(contractVerifierObjectMapper.writeValueAsString(response.payload))
+ JsonAssertion.assertThat(parsedJson).field('name').isEqualTo('some')
}
// BASE CLASS WOULD HAVE THIS:
diff --git a/tests/samples-messaging-camel/src/test/groovy/com/example/CamelMessagingApplicationSpec.groovy b/tests/samples-messaging-camel/src/test/groovy/com/example/CamelMessagingApplicationSpec.groovy
index 96702d9001..e8f8f5efa3 100644
--- a/tests/samples-messaging-camel/src/test/groovy/com/example/CamelMessagingApplicationSpec.groovy
+++ b/tests/samples-messaging-camel/src/test/groovy/com/example/CamelMessagingApplicationSpec.groovy
@@ -16,7 +16,6 @@
package com.example
-import javax.inject.Inject
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
@@ -35,6 +34,7 @@ import org.springframework.cloud.contract.verifier.messaging.internal.ContractVe
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.test.context.DynamicPropertyRegistry
import org.springframework.test.context.DynamicPropertySource
+
/**
* SPIKE ON TESTS FROM NOTES IN MessagingSpec
*/
@@ -47,7 +47,7 @@ class CamelMessagingApplicationSpec {
// ALL CASES
@Autowired
ModelCamelContext camelContext
- @Inject
+ @Autowired
ContractVerifierMessaging contractVerifierMessaging
ContractVerifierObjectMapper contractVerifierObjectMapper = new ContractVerifierObjectMapper()
diff --git a/tests/samples-messaging-integration/src/test/groovy/com/example/IntegrationMessagingApplicationSpec.groovy b/tests/samples-messaging-integration/src/test/groovy/com/example/IntegrationMessagingApplicationSpec.groovy
index b67f332f2c..738b84747d 100644
--- a/tests/samples-messaging-integration/src/test/groovy/com/example/IntegrationMessagingApplicationSpec.groovy
+++ b/tests/samples-messaging-integration/src/test/groovy/com/example/IntegrationMessagingApplicationSpec.groovy
@@ -16,7 +16,6 @@
package com.example
-import javax.inject.Inject
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
@@ -37,7 +36,7 @@ import org.springframework.messaging.Message
class IntegrationMessagingApplicationSpec {
// ALL CASES
- @Inject
+ @Autowired
ContractVerifierMessaging> contractVerifierMessaging
ContractVerifierObjectMapper contractVerifierObjectMapper = new ContractVerifierObjectMapper()
diff --git a/tests/samples-messaging-jms/src/test/groovy/com/example/JmsMessagingApplicationSpec.groovy b/tests/samples-messaging-jms/src/test/groovy/com/example/JmsMessagingApplicationSpec.groovy
index d39bea3b77..9516a5216e 100644
--- a/tests/samples-messaging-jms/src/test/groovy/com/example/JmsMessagingApplicationSpec.groovy
+++ b/tests/samples-messaging-jms/src/test/groovy/com/example/JmsMessagingApplicationSpec.groovy
@@ -16,11 +16,6 @@
package com.example
-import org.junit.jupiter.api.condition.EnabledForJreRange
-import org.junit.jupiter.api.condition.JRE
-
-import javax.inject.Inject
-
import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import com.toomuchcoding.jsonassert.JsonAssertion
@@ -28,6 +23,8 @@ import jakarta.jms.JMSException
import jakarta.jms.Message
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.condition.EnabledForJreRange
+import org.junit.jupiter.api.condition.JRE
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
@@ -38,6 +35,7 @@ import org.springframework.cloud.contract.verifier.messaging.internal.ContractVe
import org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierObjectMapper
import org.springframework.jms.core.JmsTemplate
import org.springframework.jms.core.MessagePostProcessor
+
/**
* SPIKE ON TESTS FROM NOTES IN MessagingSpec
*/
@@ -50,9 +48,9 @@ class JmsMessagingApplicationSpec {
// ALL CASES
@Autowired
JmsTemplate jmsTemplate
- @Inject
+ @Autowired
ContractVerifierMessaging contractVerifierMessaging
- @Inject
+ @Autowired
ContractVerifierObjectMapper contractVerifierObjectMapper
@BeforeAll