use of au.com.dius.pact.consumer.model.MockProviderConfig in project pact-jvm by DiUS.
the class ConsumerPactTest method testPact.
@Test
public void testPact() throws Throwable {
RequestResponsePact pact = createPact(ConsumerPactBuilder.consumer(consumerName()).hasPactWith(providerName()));
final MockProviderConfig config = MockProviderConfig.createDefault(getSpecificationVersion());
PactVerificationResult result = runConsumerTest(pact, config, (mockServer, context) -> {
runTest(mockServer, context);
return null;
});
Metrics.INSTANCE.sendMetrics(new MetricEvent.ConsumerTestRun(pact.getInteractions().size(), "junit"));
if (!(result instanceof PactVerificationResult.Ok)) {
if (result instanceof PactVerificationResult.Error) {
PactVerificationResult.Error error = (PactVerificationResult.Error) result;
if (!(error.getMockServerState() instanceof PactVerificationResult.Ok)) {
throw new AssertionError("Pact Test function failed with an exception, possibly due to " + error.getMockServerState(), ((PactVerificationResult.Error) result).getError());
} else {
throw new AssertionError("Pact Test function failed with an exception: " + error.getError().getMessage(), error.getError());
}
} else {
throw new PactMismatchesException(result);
}
}
}
Aggregations