|
15 | 15 | */ |
16 | 16 | package de.openknowledge.sample.address; |
17 | 17 |
|
| 18 | +import static java.util.Optional.ofNullable; |
| 19 | + |
18 | 20 | import org.apache.meecrowave.Meecrowave; |
19 | 21 | import org.apache.meecrowave.junit5.MonoMeecrowaveConfig; |
20 | 22 | import org.apache.meecrowave.testing.ConfigurationInject; |
|
25 | 27 | import au.com.dius.pact.provider.junit5.HttpTestTarget; |
26 | 28 | import au.com.dius.pact.provider.junit5.PactVerificationContext; |
27 | 29 | import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; |
| 30 | +import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; |
28 | 31 | import au.com.dius.pact.provider.junitsupport.Provider; |
29 | 32 | import au.com.dius.pact.provider.junitsupport.State; |
30 | | -import au.com.dius.pact.provider.junitsupport.loader.PactFolder; |
| 33 | +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; |
31 | 34 |
|
| 35 | +@IgnoreNoPactsToVerify |
32 | 36 | @Provider("address-validation-service") |
33 | | -@PactFolder("src/test/pacts") |
| 37 | +@PactBroker(url = "${pactBroker.url:http://localhost:5000}") |
34 | 38 | @MonoMeecrowaveConfig |
35 | 39 | public class AddressValidationServiceTest { |
36 | 40 |
|
37 | 41 | @ConfigurationInject |
38 | 42 | private Meecrowave.Builder config; |
39 | 43 |
|
40 | 44 | @BeforeEach |
41 | | - public void setUp(PactVerificationContext context) { |
42 | | - context.setTarget(new HttpTestTarget("localhost", config.getHttpPort(), "/")); |
| 45 | + public void setUp(PactVerificationContext verificationContext) { |
| 46 | + ofNullable(verificationContext) |
| 47 | + .ifPresent(context -> context.setTarget(new HttpTestTarget("localhost", config.getHttpPort(), "/"))); |
43 | 48 | } |
44 | 49 |
|
45 | 50 | @TestTemplate |
46 | 51 | @ExtendWith(PactVerificationInvocationContextProvider.class) |
47 | 52 | void pactVerificationTestTemplate(PactVerificationContext context) { |
48 | | - context.verifyInteraction(); |
| 53 | + ofNullable(context).ifPresent(PactVerificationContext::verifyInteraction); |
49 | 54 | } |
50 | 55 |
|
51 | 56 | @State("Three customers") |
|
0 commit comments