use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class PactVerificationsForMultipleFragmentsTest method messagePact.
@Pact(provider = MESSAGE_PROVIDER_NAME, consumer = PACT_VERIFICATIONS_CONSUMER_NAME)
public MessagePact messagePact(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParam1", "value1");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("contentType", "application/json");
return builder.given("SomeProviderState").expectsToReceive("a test message").withMetadata(metadata).withContent(body).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class PactVerificationsForMultipleHttpsAndMessagesTest method otherMessagePact.
@Pact(provider = OTHER_MESSAGE_PROVIDER_NAME, consumer = PACT_VERIFICATIONS_CONSUMER_NAME)
public MessagePact otherMessagePact(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParamA", "valueA");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("contentType", "application/json");
return builder.given("SomeOtherProviderState").expectsToReceive("another test message").withMetadata(metadata).withContent(body).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class MessageWithMetadataConsumerTest method createPact.
@Pact(consumer = "test_consumer_v3")
public MessagePact createPact(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParam1", "value1");
body.stringValue("testParam2", "value2");
return builder.given("SomeProviderState").expectsToReceive("a test message with metadata").withMetadata(md -> {
md.add("metadata1", "metadataValue1");
md.add("metadata2", "metadataValue2");
md.add("metadata3", 10L);
md.matchRegex("partitionKey", "[A-Z]{3}\\d{2}", "ABC01");
}).withContent(body).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class Defect371Test method createPact2.
@Pact(provider = "provider2", consumer = "Defect371")
public MessagePact createPact2(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParam1", "value3");
body.stringValue("testParam2", "value4");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("contentType", "application/json");
return builder.given("Some Other Provider State").expectsToReceive("a test message").withMetadata(metadata).withContent(body).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class EventsRepositoryDictionaryNestedArrayConsumerTest method createPact.
@Pact(provider = "EventsProvider", consumer = "EventsConsumerDictionaryNestedArray")
public RequestResponsePact createPact(PactDslWithProvider builder) {
DslPart body = new PactDslJsonBody().object("events").eachKeyMappedToAnArrayLike(// broken, see pact-jvm issue 401
"ant").stringType("title", "ant");
RequestResponsePact pact = builder.given("initialStateForEventsTest").uponReceiving("a request to get events keyed by title").path("/dictionaryNestedArray").headers("Accept", ContentType.APPLICATION_JSON.toString()).method("GET").willRespondWith().status(200).body(body).toPact();
MatcherTestUtils.assertResponseMatcherKeysEqualTo(pact, "body", "$.events", "$.events.*[*].title");
HashMap<String, MatchingRuleGroup> matchingRules = new HashMap<>();
matchingRules.put("$.events", new MatchingRuleGroup(Collections.singletonList(ValuesMatcher.INSTANCE)));
matchingRules.put("$.events.*[*].title", new MatchingRuleGroup(Collections.singletonList(TypeMatcher.INSTANCE)));
assertThat(pact.getInteractions().get(0).asSynchronousRequestResponse().getResponse().getMatchingRules().rulesForCategory("body").getMatchingRules(), is(equalTo(matchingRules)));
return pact;
}
Aggregations