Search in sources :

Example 6 with MessagePact

use of au.com.dius.pact.model.v3.messaging.MessagePact in project pact-jvm by DiUS.

the class AsyncMessageTest method createPact.

@Pact(provider = "test_provider", consumer = "test_consumer_v3")
public MessagePact createPact(MessagePactBuilder builder) {
    PactDslJsonBody body = new PactDslJsonBody();
    body.stringValue("testParam1", "value1");
    body.stringValue("testParam2", "value2");
    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) Pact(au.com.dius.pact.consumer.Pact) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact)

Example 7 with MessagePact

use of au.com.dius.pact.model.v3.messaging.MessagePact 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();
}
Also used : 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 8 with MessagePact

use of au.com.dius.pact.model.v3.messaging.MessagePact in project pact-jvm by DiUS.

the class ExampleMessageConsumerTest method createPact.

@Pact(provider = "test_provider", consumer = "test_consumer_v3")
public MessagePact createPact(MessagePactBuilder builder) {
    PactDslJsonBody body = new PactDslJsonBody();
    body.stringValue("testParam1", "value1");
    body.stringValue("testParam2", "value2");
    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) Pact(au.com.dius.pact.consumer.Pact) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact)

Example 9 with MessagePact

use of au.com.dius.pact.model.v3.messaging.MessagePact in project pact-jvm by DiUS.

the class ExampleMessageConsumerWithRootArrayTest method createPact.

@Pact(provider = "test_provider", consumer = "test_consumer_v3")
public MessagePact createPact(MessagePactBuilder builder) {
    PactDslJsonArray body = new PactDslJsonArray().decimalType(100.10).stringType("Should be in an array");
    Map<String, String> metadata = new HashMap<String, String>();
    metadata.put("contentType", "application/json");
    return builder.given("SomeProviderState").expectsToReceive("a test message with an array").withMetadata(metadata).withContent(body).toPact();
}
Also used : PactDslJsonArray(au.com.dius.pact.consumer.dsl.PactDslJsonArray) HashMap(java.util.HashMap) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) Pact(au.com.dius.pact.consumer.Pact)

Example 10 with MessagePact

use of au.com.dius.pact.model.v3.messaging.MessagePact 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)

Aggregations

MessagePact (au.com.dius.pact.model.v3.messaging.MessagePact)17 Pact (au.com.dius.pact.consumer.Pact)13 HashMap (java.util.HashMap)13 PactDslJsonBody (au.com.dius.pact.consumer.dsl.PactDslJsonBody)12 RequestResponsePact (au.com.dius.pact.model.RequestResponsePact)5 Method (java.lang.reflect.Method)3 Message (au.com.dius.pact.model.v3.messaging.Message)2 PactDslJsonArray (au.com.dius.pact.consumer.dsl.PactDslJsonArray)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Statement (org.junit.runners.model.Statement)1