Search in sources :

Example 6 with PactDslJsonBody

use of au.com.dius.pact.consumer.dsl.PactDslJsonBody in project pact-jvm by DiUS.

the class ExampleMessageConsumerWithV2MatchersTest method createPact.

@Pact(provider = "test_provider_v3", consumer = "test_consumer_v3")
public MessagePact createPact(MessagePactBuilder builder) {
    PactDslJsonBody body = new PactDslJsonBody().uuid("workflowId").stringType("domain").eachLike("values").stringType("key").stringType("value").closeObject().closeArray().asBody();
    Map<String, String> metaData = new HashMap<>();
    metaData.put("contentType", "application/json");
    MessagePact messagePact = builder.given("executing a workflow with rabbitmq").expectsToReceive("execution payload").withContent(body).withMetadata(metaData).toPact();
    MatcherTestUtils.assertMessageMatcherKeysEqualTo(messagePact, "$.body.workflowId", "$.body.domain", "$.body.values", "$.body.values", "$.body.values[*].key", "$.body.values[*].value");
    return messagePact;
}
Also used : MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) HashMap(java.util.HashMap) PactDslJsonBody(au.com.dius.pact.consumer.dsl.PactDslJsonBody) Pact(au.com.dius.pact.consumer.Pact) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact)

Example 7 with PactDslJsonBody

use of au.com.dius.pact.consumer.dsl.PactDslJsonBody 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();
}
Also used : HashMap(java.util.HashMap) PactDslJsonBody(au.com.dius.pact.consumer.dsl.PactDslJsonBody) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) Pact(au.com.dius.pact.consumer.Pact) RequestResponsePact(au.com.dius.pact.model.RequestResponsePact)

Example 8 with PactDslJsonBody

use of au.com.dius.pact.consumer.dsl.PactDslJsonBody in project pact-jvm by DiUS.

the class PactVerificationsForMultipleFragmentsTest method otherMessagePact.

@Pact(provider = 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();
}
Also used : HashMap(java.util.HashMap) PactDslJsonBody(au.com.dius.pact.consumer.dsl.PactDslJsonBody) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) Pact(au.com.dius.pact.consumer.Pact) RequestResponsePact(au.com.dius.pact.model.RequestResponsePact)

Example 9 with PactDslJsonBody

use of au.com.dius.pact.consumer.dsl.PactDslJsonBody 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();
}
Also used : HashMap(java.util.HashMap) PactDslJsonBody(au.com.dius.pact.consumer.dsl.PactDslJsonBody) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) Pact(au.com.dius.pact.consumer.Pact) RequestResponsePact(au.com.dius.pact.model.RequestResponsePact)

Example 10 with PactDslJsonBody

use of au.com.dius.pact.consumer.dsl.PactDslJsonBody in project pact-jvm by DiUS.

the class PactVerificationsForMultipleHttpsAndMessagesTest 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();
}
Also used : HashMap(java.util.HashMap) PactDslJsonBody(au.com.dius.pact.consumer.dsl.PactDslJsonBody) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) Pact(au.com.dius.pact.consumer.Pact) RequestResponsePact(au.com.dius.pact.model.RequestResponsePact)

Aggregations

PactDslJsonBody (au.com.dius.pact.consumer.dsl.PactDslJsonBody)27 HashMap (java.util.HashMap)14 Pact (au.com.dius.pact.consumer.Pact)12 MessagePact (au.com.dius.pact.model.v3.messaging.MessagePact)12 DslPart (au.com.dius.pact.consumer.dsl.DslPart)11 Test (org.junit.Test)11 RequestResponsePact (au.com.dius.pact.model.RequestResponsePact)9 HashSet (java.util.HashSet)7 JSONObject (org.json.JSONObject)6 ConsumerPactRunnerKt.runConsumerTest (au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest)4 PactDslJsonArray (au.com.dius.pact.consumer.dsl.PactDslJsonArray)1 Date (java.util.Date)1 Map (java.util.Map)1 JSONArray (org.json.JSONArray)1