contract-testing-demo
pact and java contract testing with micro-commits
commit cc16e125dc76cf9b986b553c5af286f3b56ffad1 parent 18fcf94515f384eaf0b6d676079ddb9d4c00dbf8 Author: Jul <jul@9o.is> Date: Wed, 26 Jun 2019 15:37:01 -0400 Write failing provider test Test: Given there does not exist an alligator named Mary, upon receiving a request for Mary the alligator, a 404 is returned. Diffstat:
| M | consumer-driven/animal-service/src/test/java/app/ZooServicePactTest.java | | | 15 | ++++++++++++++- |
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/consumer-driven/animal-service/src/test/java/app/ZooServicePactTest.java b/consumer-driven/animal-service/src/test/java/app/ZooServicePactTest.java @@ -47,7 +47,20 @@ public class ZooServicePactTest { verify(alligatorRepository).getByName("Mary"); } - public void alligatorMaryDoesNotExist() {} + @State("there does not exist an alligator named Mary") + public void alligatorMaryDoesNotExist() { + when(alligatorRepository.getByName("Mary")) + .thenReturn(null); + } + + @State( + value = "there does not exist an alligator named Mary", + action = StateChangeAction.TEARDOWN + ) + public void alligatorMaryDoesNotExistVerification() { + verify(alligatorRepository).getByName("Mary"); + } + public void animalServiceIsUnavailable() {} @Before