Skip to content

Commit 5d2d19a

Browse files
committed
fix: DeliveryAddressRepositoryTest
1 parent d37f99c commit 5d2d19a

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
cache: maven
1818

1919
- name: Build customer-service
20-
run: mvn clean package -f customer-service/pom.xml -DskipTests
20+
run: mvn clean package -f customer-service/pom.xml
2121

2222
- name: Build billing-service
2323
run: mvn clean package -f billing-service/pom.xml

customer-service/src/test/java/de/openknowledge/sample/address/domain/DeliveryAddressRepositoryTest.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.junit.jupiter.api.extension.ExtendWith;
3131

3232
import au.com.dius.pact.consumer.MockServer;
33+
import au.com.dius.pact.consumer.dsl.PactDslJsonBody;
3334
import au.com.dius.pact.consumer.dsl.PactDslWithProvider;
3435
import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
3536
import au.com.dius.pact.consumer.junit5.PactTestFor;
@@ -48,10 +49,17 @@ public V4Pact getMax(PactDslWithProvider builder) throws IOException {
4849
return builder
4950
.given("Three customers")
5051
.uponReceiving("GET request for 0815")
51-
.method("GET")
5252
.path("/delivery-addresses/0815")
53+
.method("GET")
5354
.willRespondWith()
5455
.status(200)
56+
.body(new PactDslJsonBody()
57+
.stringValue("recipient", "Max Mustermann")
58+
.stringValue("city", "26122 Oldenburg")
59+
.object("street")
60+
.stringValue("name", "Poststr.")
61+
.stringValue("number", "1")
62+
.closeObject())
5563
.toPact(V4Pact.class);
5664
}
5765

@@ -63,7 +71,7 @@ public V4Pact dontGetMissing(PactDslWithProvider builder) throws IOException {
6371
.path("/delivery-addresses/0817")
6472
.method("GET")
6573
.willRespondWith()
66-
.status(204)
74+
.status(404)
6775
.toPact(V4Pact.class);
6876
}
6977

@@ -75,6 +83,13 @@ public V4Pact updateMax(PactDslWithProvider builder) throws IOException {
7583
.path("/delivery-addresses/0815")
7684
.method("POST")
7785
.matchHeader("Content-Type", "application/json.*", "application/json")
86+
.body(new PactDslJsonBody()
87+
.stringValue("recipient", "Erika Mustermann")
88+
.stringValue("city", "45127 Essen")
89+
.object("street")
90+
.stringValue("name", "II. Hagen")
91+
.stringValue("number", "7")
92+
.closeObject())
7893
.willRespondWith()
7994
.status(200)
8095
.toPact(V4Pact.class);
@@ -85,10 +100,20 @@ public V4Pact dontUpdateSherlock(PactDslWithProvider builder) throws IOException
85100
return builder
86101
.given("Three customers")
87102
.uponReceiving("POST request for 007")
88-
.method("POST")
89103
.path("/delivery-addresses/007")
104+
.method("POST")
105+
.matchHeader("Content-Type", "application/json.*", "application/json")
106+
.body(new PactDslJsonBody()
107+
.stringValue("recipient", "Sherlock Holmes")
108+
.stringValue("city", "London NW1 6XE")
109+
.object("street")
110+
.stringValue("name", "Baker Street")
111+
.stringValue("number", "221B")
112+
.closeObject())
90113
.willRespondWith()
91114
.status(400)
115+
.matchHeader("Content-Type", "application/problem\\+json.*", "application/problem+json")
116+
.body(new PactDslJsonBody().stringMatcher("detail", ".*", "Addresses from UK are not supported for delivery"))
92117
.toPact(V4Pact.class);
93118
}
94119

0 commit comments

Comments
 (0)