diff --git a/CHANGELOG.md b/CHANGELOG.md index 195616103..915dba2a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD` replacing TAGNAME and HEAD as appropriate. +# 4.6.16 - Maintenance Release + +* 2d2016317 - fix: Dependency conflict with org.slf4j:slf4j-api was causing Spring tests to fail (Ronald Holshausen, Wed Dec 4 14:21:15 2024 +1100) +* 38c0d27b8 - feat: Update LambdaDsl.newJsonArray to allow setting the number of examples (Ronald Holshausen, Wed Dec 4 10:59:23 2024 +1100) +* 19c663c8c - chore: The pact-jvm-server main spec was not configured correctly (Ronald Holshausen, Wed Dec 4 10:24:23 2024 +1100) +* 147a2a661 - fix: LambdaDslJsonArray has no datetime function #1839 (Ronald Holshausen, Wed Dec 4 10:23:10 2024 +1100) +* c7911705b - chore: Update readme (Ronald Holshausen, Wed Dec 4 09:59:01 2024 +1100) +* 7229244f6 - Merge pull request #1837 from cburgmer/patch-1 (Ronald Holshausen, Fri Nov 15 10:03:21 2024 +1100) +* e95461a6a - Fix path to Clojure example (Christoph Burgmer, Thu Nov 14 14:21:10 2024 +0100) +* 9f6b209e2 - chore: Add a test + update docs on JUnit 4 report dir default #1836 (Ronald Holshausen, Thu Nov 14 15:58:48 2024 +1100) +* 3e501f58e - chore: Add a test for pact-jvm-server (Ronald Holshausen, Tue Oct 29 17:40:28 2024 +1100) +* 85c92365e - Update README.md (Ronald Holshausen, Tue Oct 29 11:32:02 2024 +1100) +* 5c41e17fc - bump version to 4.6.16 (Ronald Holshausen, Tue Oct 29 10:38:07 2024 +1100) + # 4.7.0-beta.0 - First beta release * 2d69044ca - chore: Correct release script for Gradle 8.11 (Ronald Holshausen, Wed Dec 4 09:29:37 2024 +1100) diff --git a/README.md b/README.md index fa2dc97f2..7ba1f5e29 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ and in the [Pact-JVM wiki](https://github.com/pact-foundation/pact-jvm/wiki). [S | Branch | Specification | JDK | Kotlin Version | Latest Version | Notes | |-----------------------------------------------------------------------------------|---------------|-----------------------|----------------|----------------|-------| | [4.7.x](https://github.com/pact-foundation/pact-jvm/blob/v4.7.x/README.md) | V4 + plugins | 17+ (tested up to 23) | 2.0.21 | 4.7.0-beta.0 | | -| [4.6.x](https://github.com/pact-foundation/pact-jvm/blob/v4.6.x/README.md) master | V4 + plugins | 17-18 | 1.8.22 | 4.6.15 | | -| [4.5.x](https://github.com/pact-foundation/pact-jvm/blob/v4.5.x/README.md) | V4 + plugins | 11+/17(1) | 1.7.20 | 4.5.13 | | +| [4.6.x](https://github.com/pact-foundation/pact-jvm/blob/v4.6.x/README.md) master | V4 + plugins | 17+ (tested up to 18) | 1.8.22 | 4.6.15 | | +| [4.5.x](https://github.com/pact-foundation/pact-jvm/blob/v4.5.x/README.md) | V4 + plugins | 11+/17+(1) | 1.7.20 | 4.5.13 | | | [4.1.x](https://github.com/pact-foundation/pact-jvm/blob/v4.1.x/README.md) | V3 | 8-12 | 1.3.72 | 4.1.43 | | **Notes:** diff --git a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle index ee2d8d981..45b0d52a0 100644 --- a/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle +++ b/buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle @@ -41,7 +41,7 @@ dependencies { implementation 'org.apache.commons:commons-collections4:4.4' implementation 'org.apache.tika:tika-core:2.9.1' implementation 'com.google.guava:guava:31.1-jre' - implementation 'org.slf4j:slf4j-api:1.7.36' + implementation 'org.slf4j:slf4j-api:2.0.4' implementation 'io.ktor:ktor-http-jvm:3.0.1' implementation 'io.ktor:ktor-server-netty:3.0.1' implementation 'io.ktor:ktor-network-tls-certificates:3.0.1' diff --git a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java index 459d1313d..9de883d50 100644 --- a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java +++ b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDsl.java @@ -24,6 +24,18 @@ public static LambdaDslJsonArray newJsonArray(Consumer array return dslArray; } + /** + * DSL function to simplify creating a {@link DslPart} generated from a {@link LambdaDslJsonArray}. + * @param examples Number of examples to populate the array with + */ + public static LambdaDslJsonArray newJsonArray(Integer examples, Consumer array) { + final PactDslJsonArray pactDslJsonArray = new PactDslJsonArray(); + pactDslJsonArray.setNumberExamples(examples); + final LambdaDslJsonArray dslArray = new LambdaDslJsonArray(pactDslJsonArray); + array.accept(dslArray); + return dslArray; + } + /** * DSL function to simplify creating a {@link DslPart} generated from a {@link LambdaDslJsonArray} where a minimum base array size is specified */ diff --git a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java index 68dd69705..461047495 100644 --- a/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java +++ b/consumer/src/main/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArray.java @@ -304,8 +304,7 @@ public LambdaDslJsonArray time(final String format, final Date example) { */ @Deprecated public LambdaDslJsonArray timestamp() { - pactArray.datetime(); - return this; + return datetime(); } /** @@ -316,8 +315,7 @@ public LambdaDslJsonArray timestamp() { */ @Deprecated public LambdaDslJsonArray timestamp(final String format) { - pactArray.datetime(format); - return this; + return datetime(format); } /** @@ -329,8 +327,7 @@ public LambdaDslJsonArray timestamp(final String format) { */ @Deprecated public LambdaDslJsonArray timestamp(final String format, final Date example) { - pactArray.datetime(format, example); - return this; + return datetime(format, example); } /** @@ -342,10 +339,49 @@ public LambdaDslJsonArray timestamp(final String format, final Date example) { */ @Deprecated public LambdaDslJsonArray timestamp(final String format, final Instant example) { - pactArray.datetime(format, example); - return this; + return datetime(format, example); } + /** + * Element that must be an ISO formatted date/time + */ + public LambdaDslJsonArray datetime() { + pactArray.datetime(); + return this; + } + + /** + * Element that must match the given date/time format + * + * @param format date/time format + */ + public LambdaDslJsonArray datetime(final String format) { + pactArray.datetime(format); + return this; + } + + /** + * Element that must match the given date/time format + * + * @param format date/time format + * @param example example date and time to use for generated bodies + */ + public LambdaDslJsonArray datetime(final String format, final Date example) { + pactArray.datetime(format, example); + return this; + } + + /** + * Element that must match the given date/time format + * + * @param format date/time format + * @param example example date and time to use for generated bodies + */ + public LambdaDslJsonArray datetime(final String format, final Instant example) { + pactArray.datetime(format, example); + return this; + } + /** * Element that must be a numeric identifier */ diff --git a/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java b/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java index 1fcb958ca..919e87856 100644 --- a/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java +++ b/consumer/src/test/java/au/com/dius/pact/consumer/dsl/LambdaDslJsonArrayTest.java @@ -764,4 +764,21 @@ public void testUnorderedArrayMatcher() { assertThat(lambdaPactDsl.getMatchers(), is(pactDslJson.getMatchers())); } + @Test + public void arrayEachLike() { + // Old DSL + final DslPart pactDslJson = PactDslJsonArray + .arrayEachLike(2) + .stringType("name", "Berlin") + .close(); + + // Lambda DSL + final DslPart lambdaPactDsl = LambdaDsl.newJsonArray(2, array -> + array.object(obj -> + obj.stringType("name", "Berlin") + ) + ).build().close(); + + assertThat(lambdaPactDsl.getBody().toString(), is(pactDslJson.getBody().toString())); + } } diff --git a/provider/junit5spring/build.gradle b/provider/junit5spring/build.gradle index e46c2c8e6..e96a1c644 100644 --- a/provider/junit5spring/build.gradle +++ b/provider/junit5spring/build.gradle @@ -17,7 +17,9 @@ dependencies { implementation 'org.apache.commons:commons-lang3' implementation 'javax.mail:mail:1.5.0-b01' - testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.14' - testImplementation 'org.springframework.boot:spring-boot-starter-web:2.5.14' + testImplementation 'org.springframework.boot:spring-boot-test:2.5.14' + testImplementation 'org.springframework.boot:spring-boot-test-autoconfigure:2.5.14' + testImplementation 'org.springframework:spring-webmvc:5.3.20' testImplementation 'org.apache.groovy:groovy' + testImplementation 'org.yaml:snakeyaml:1.33' } diff --git a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java index 9a8126bab..379859991 100644 --- a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java +++ b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/MockMvcTestTargetWebMvcTestJava.java @@ -5,7 +5,6 @@ import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; @@ -24,7 +23,6 @@ @WebMvcTest @Provider("myAwesomeService") @PactFolder("pacts") -@Disabled // TODO: this fails with NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder class MockMvcTestTargetWebMvcTestJava { @Autowired diff --git a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java index 39762977b..0c55c023a 100644 --- a/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java +++ b/provider/junit5spring/src/test/java/au/com/dius/pact/provider/spring/junit5/WebTestClientPactTest.java @@ -4,7 +4,6 @@ import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; @@ -18,7 +17,6 @@ @SpringBootTest @Provider("myAwesomeService") @PactFolder("pacts") -@Disabled // TODO: this fails with NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder class WebTestClientPactTest { public static class Handler { diff --git a/provider/spring/README.md b/provider/spring/README.md index 5125919cb..01cc7d539 100644 --- a/provider/spring/README.md +++ b/provider/spring/README.md @@ -198,7 +198,7 @@ public class PactVerificationTest { ``` #### JUnit5 -You actually don't need to dependend on `pact-jvm-provider-spring` for this. It's sufficient to depend on `pact-jvm-provider-junit5`. +You actually don't need to depend on `pact-jvm-provider-spring` for this. It's sufficient to depend on `pact-jvm-provider-junit5`. You can set the port to the `HttpTestTarget` object in the before method.