contract-testing-demo
pact and java contract testing with micro-commits
commit 54559fa28e6af0c2ca01a7e07d4f8460eaba4618 parent ed5591849e83f190f3516776d41c3dfd55f16c34 Author: Jul <jul@9o.is> Date: Wed, 26 Jun 2019 15:21:39 -0400 Extract Pact provider to a field - refactoring Diffstat:
| M | consumer-driven/zoo-service/src/test/java/AnimalServicePactTest.java | | | 14 | ++++++++------ |
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/consumer-driven/zoo-service/src/test/java/AnimalServicePactTest.java b/consumer-driven/zoo-service/src/test/java/AnimalServicePactTest.java @@ -1,5 +1,6 @@ import au.com.dius.pact.consumer.ConsumerPactBuilder; import au.com.dius.pact.consumer.PactVerificationResult; +import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.model.MockProviderConfig; import au.com.dius.pact.model.RequestResponsePact; import org.junit.Test; @@ -12,14 +13,17 @@ import static org.junit.Assert.*; public class AnimalServicePactTest { + private PactDslWithProvider withProvider = + ConsumerPactBuilder + .consumer("Zoo Service") + .hasPactWith("Animal Service"); + @Test public void alligatorMaryExists() { Map<String, String> headers = new HashMap<>(); headers.put("Content-type", "application/json"); - RequestResponsePact pact = ConsumerPactBuilder - .consumer("Zoo Service") - .hasPactWith("Animal Service") + RequestResponsePact pact = withProvider .given("there exists an alligator named Mary") .uponReceiving("a request for Mary the alligator") .method("GET") @@ -48,9 +52,7 @@ public class AnimalServicePactTest { @Test public void alligatorMaryDoesNotExist() { - RequestResponsePact pact = ConsumerPactBuilder - .consumer("Zoo Service") - .hasPactWith("Animal Service") + RequestResponsePact pact = withProvider .given("there does not exist an alligator named Mary") .uponReceiving("a request for Mary the alligator") .method("GET")