Skip to content

Commit 026b049

Browse files
authored
chore(deps): step4 - Java17 / Pact 4.6.5 (#28)
1 parent a88a4bb commit 026b049

File tree

9 files changed

+60
-23
lines changed

9 files changed

+60
-23
lines changed

.github/workflows/test.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- step4
6+
pull_request:
7+
branches:
8+
- step4
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 17
21+
distribution: 'temurin'
22+
23+
- name: Test consumer tests
24+
run: ./gradlew consumer:test
25+
- name: Test consumer pact tests
26+
run: ./gradlew consumer:test --tests '*Pact*Test'
27+
- name: Copy consumer pacts
28+
run: ./gradlew consumer:copyPacts
29+
- name: Test provider pact tests
30+
run: ./gradlew provider:test --tests '*Pact*Test' || true

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ build/
33
!../gradle/wrapper/gradle-wrapper.jar
44
!**/src/main/**/build/
55
!**/src/test/**/build/
6-
6+
consumer/bin
7+
provider/bin
78
provider/src/test/resources/pacts
89

910
### STS ###
@@ -47,3 +48,7 @@ gradle-app.setting
4748

4849
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
4950
# gradle/wrapper/gradle-wrapper.properties
51+
52+
## MacOS
53+
54+
.DS_Store

.java-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17.0

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ step of the workshop just check out the branch for that step (i.e. `git checkout
77

88
## Requirements
99

10-
* JDK 8+
10+
* JDK 17+
1111
* Docker for step 11
1212

1313
## Workshop outline:
@@ -317,14 +317,14 @@ This test starts a mock server on a random port that acts as our provider servic
317317
To run only the Pact tests:
318318

319319
```console
320-
> ./gradlew consumer:test --tests *PactTest
320+
> ./gradlew consumer:test --tests '*PactTest'
321321

322322
```
323323

324324
Running this test still passes, but it creates a pact file which we can use to validate our assumptions on the provider side, and have conversation around.
325325

326326
```console
327-
./gradlew consumer:test --tests *PactTest
327+
./gradlew consumer:test --tests '*PactTest'
328328
329329
BUILD SUCCESSFUL in 6s
330330
```
@@ -386,13 +386,13 @@ public class ProductPactProviderTest {
386386
To run only the verification tests:
387387

388388
```console
389-
> ./gradlew provider:test --tests *Pact*Test
389+
> ./gradlew provider:test --tests '*Pact*Test'
390390
```
391391

392392
We now need to validate the pact generated by the consumer is valid, by executing it against the running service provider, which should fail:
393393

394394
```console
395-
./gradlew provider:test --tests *Pact*Test
395+
./gradlew provider:test --tests '*Pact*Test'
396396

397397
...
398398
...

consumer/build.gradle

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.3.4.RELEASE'
3-
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
2+
// Stopped from moving to 3.2.x due to wiremock issue
3+
// https://github.com/wiremock/wiremock/issues/2395
4+
id 'org.springframework.boot' version '3.1.8'
5+
id 'io.spring.dependency-management' version '1.1.4'
46
}
57

68
group = 'au.com.dius.pactworkshop'
79
version = '0.0.1-SNAPSHOT'
8-
sourceCompatibility = '8'
10+
sourceCompatibility = '17'
911

1012
dependencies {
1113
implementation 'org.springframework.boot:spring-boot-starter'
@@ -14,9 +16,8 @@ dependencies {
1416
testImplementation('org.springframework.boot:spring-boot-starter-test') {
1517
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
1618
}
17-
testImplementation 'com.github.tomakehurst:wiremock:2.27.2'
18-
testImplementation 'au.com.dius.pact.consumer:java8:4.1.7'
19-
testImplementation 'au.com.dius.pact.consumer:junit5:4.1.7'
19+
testImplementation 'com.github.tomakehurst:wiremock:3.0.1'
20+
testImplementation 'au.com.dius.pact.consumer:junit5:4.6.5'
2021
}
2122

2223
test {

consumer/src/test/java/au/com/dius/pactworkshop/consumer/ProductConsumerPactTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
import org.junit.jupiter.api.extension.ExtendWith;
1111
import org.springframework.boot.web.client.RestTemplateBuilder;
1212
import org.springframework.web.client.RestTemplate;
13-
13+
import au.com.dius.pact.core.model.PactSpecVersion; // required for v4.6.x to set pactVersion
1414
import java.util.Arrays;
1515
import java.util.HashMap;
1616
import java.util.List;
1717
import java.util.Map;
1818

19-
import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonArrayMinLike;
20-
import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody;
19+
import static au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonArrayMinLike;
20+
import static au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody;
2121
import static org.junit.jupiter.api.Assertions.assertEquals;
2222

2323
@ExtendWith(PactConsumerTestExt.class)
@@ -60,7 +60,7 @@ RequestResponsePact getOneProduct(PactDslWithProvider builder) {
6060
}
6161

6262
@Test
63-
@PactTestFor(pactMethod = "getAllProducts")
63+
@PactTestFor(pactMethod = "getAllProducts", pactVersion = PactSpecVersion.V3)
6464
void getAllProducts_whenProductsExist(MockServer mockServer) {
6565
Product product = new Product();
6666
product.setId("09");
@@ -77,7 +77,7 @@ void getAllProducts_whenProductsExist(MockServer mockServer) {
7777
}
7878

7979
@Test
80-
@PactTestFor(pactMethod = "getOneProduct")
80+
@PactTestFor(pactMethod = "getOneProduct", pactVersion = PactSpecVersion.V3)
8181
void getProductById_whenProductWithId10Exists(MockServer mockServer) {
8282
Product expected = new Product();
8383
expected.setId("10");
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

provider/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.3.4.RELEASE'
3-
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
2+
id 'org.springframework.boot' version '3.2.2'
3+
id 'io.spring.dependency-management' version '1.1.4'
44
}
55

66
group = 'au.com.dius.pactworkshop'
77
version = '0.0.1-SNAPSHOT'
8-
sourceCompatibility = '8'
8+
sourceCompatibility = '17'
99

1010
dependencies {
1111
implementation 'org.springframework.boot:spring-boot-starter'
@@ -14,7 +14,7 @@ dependencies {
1414
testImplementation('org.springframework.boot:spring-boot-starter-test') {
1515
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
1616
}
17-
testImplementation("au.com.dius.pact.provider:junit5:4.1.7")
17+
testImplementation("au.com.dius.pact.provider:junit5:4.6.5")
1818
}
1919

2020
test {

provider/src/test/java/au/com/dius/pactworkshop/provider/ProductPactProviderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.junit.jupiter.api.TestTemplate;
1111
import org.junit.jupiter.api.extension.ExtendWith;
1212
import org.springframework.boot.test.context.SpringBootTest;
13-
import org.springframework.boot.web.server.LocalServerPort;
13+
import org.springframework.boot.test.web.server.LocalServerPort;
1414
import org.springframework.test.context.junit.jupiter.SpringExtension;
1515

1616
@Provider("ProductService")

0 commit comments

Comments
 (0)