Skip to content

Commit 7897eba

Browse files
authored
chore(deps): step3 - Java17 / Pact 4.6.5 (#27)
1 parent 4f2d35d commit 7897eba

File tree

8 files changed

+53
-19
lines changed

8 files changed

+53
-19
lines changed

.github/workflows/test.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- step3
6+
pull_request:
7+
branches:
8+
- step3
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'

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
consumer/.gradle
1+
.gradle
22
build/
33
!../gradle/wrapper/gradle-wrapper.jar
44
!**/src/main/**/build/
55
!**/src/test/**/build/
6+
consumer/bin
7+
provider/bin
68

79
### STS ###
810
.apt_generated
@@ -45,3 +47,7 @@ gradle-app.setting
4547

4648
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
4749
# gradle/wrapper/gradle-wrapper.properties
50+
51+
## MacOS
52+
53+
.DS_Store

.java-version

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

README.md

+3-3
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
```

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

+3-3
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'

0 commit comments

Comments
 (0)