Search in sources :

Example 16 with MessagePact

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

the class ExampleMessageConsumerWithGetMessageFromRuleTest method createPact.

@Pact(provider = "message_test_provider", consumer = "message_test_consumer")
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 17 with MessagePact

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

the class PactVerificationsForHttpAndMessageTest 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");
    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) MessagePact(au.com.dius.pact.model.v3.messaging.MessagePact) Pact(au.com.dius.pact.consumer.Pact) RequestResponsePact(au.com.dius.pact.model.RequestResponsePact)

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