use of au.com.dius.pact.core.matchers.Mismatch in project pact-jvm by DiUS.
the class PactMultiProviderTest method bothprovidersFail.
@Test
@PactVerification(value = { "test_provider", "test_provider2" })
public void bothprovidersFail() throws IOException {
mockTestProvider.validateResultWith((result, t) -> {
assertThat(t, is(instanceOf(AssertionError.class)));
assertThat(t.getMessage(), startsWith("The following mismatched requests occurred:\nUnexpected Request:\n\tmethod: GET\n\tpath: /abc"));
assertThat(result, is(instanceOf(PactVerificationResult.Mismatches.class)));
PactVerificationResult.Mismatches error = (PactVerificationResult.Mismatches) result;
assertThat(error.getMismatches(), hasSize(1));
PactVerificationResult result1 = error.getMismatches().get(0);
assertThat(result1, is(instanceOf(PactVerificationResult.UnexpectedRequest.class)));
PactVerificationResult.UnexpectedRequest unexpectedRequest = (PactVerificationResult.UnexpectedRequest) result1;
assertThat(unexpectedRequest.getRequest().getPath(), is("/abc"));
});
mockTestProvider2.validateResultWith((result, t) -> {
assertThat(t, is(instanceOf(AssertionError.class)));
assertThat(t.getMessage(), is("The following mismatched requests occurred:\n" + "body - $.name: Expected 'larry' (String) but received 'farry' (String)"));
assertThat(result, is(instanceOf(PactVerificationResult.Mismatches.class)));
PactVerificationResult.Mismatches error = (PactVerificationResult.Mismatches) result;
assertThat(error.getMismatches(), hasSize(1));
PactVerificationResult result1 = error.getMismatches().get(0);
assertThat(result1, is(instanceOf(PactVerificationResult.PartialMismatch.class)));
PactVerificationResult.PartialMismatch error1 = (PactVerificationResult.PartialMismatch) result1;
assertThat(error1.getMismatches(), hasSize(1));
Mismatch mismatch = error1.getMismatches().get(0);
assertThat(mismatch, is(instanceOf(BodyMismatch.class)));
});
doTest("/abc", "{\"name\": \"farry\"}");
}
use of au.com.dius.pact.core.matchers.Mismatch in project pact-jvm by DiUS.
the class PactMultiProviderTest method provider2Fails.
@Test
@PactVerification(value = { "test_provider", "test_provider2" })
public void provider2Fails() throws IOException {
mockTestProvider2.validateResultWith((result, t) -> {
assertThat(t, is(instanceOf(AssertionError.class)));
assertThat(t.getMessage(), is("The following mismatched requests occurred:\n" + "body - $.name: Expected 'larry' (String) but received 'farry' (String)"));
assertThat(result, is(instanceOf(PactVerificationResult.Mismatches.class)));
PactVerificationResult.Mismatches error = (PactVerificationResult.Mismatches) result;
assertThat(error.getMismatches(), hasSize(1));
PactVerificationResult result1 = error.getMismatches().get(0);
assertThat(result1, is(instanceOf(PactVerificationResult.PartialMismatch.class)));
PactVerificationResult.PartialMismatch error1 = (PactVerificationResult.PartialMismatch) result1;
assertThat(error1.getMismatches(), hasSize(1));
Mismatch mismatch = error1.getMismatches().get(0);
assertThat(mismatch, is(instanceOf(BodyMismatch.class)));
});
doTest("/", "{\"name\": \"farry\"}");
}
Aggregations