Search in sources :

Example 1 with Pact

use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.

the class Defect371Test method createPact.

@Pact(provider = "provider1", consumer = "Defect371")
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.core.model.annotations.Pact) MessagePact(au.com.dius.pact.core.model.messaging.MessagePact)

Example 2 with Pact

use of au.com.dius.pact.core.model.annotations.Pact 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.core.model.annotations.Pact) MessagePact(au.com.dius.pact.core.model.messaging.MessagePact)

Example 3 with Pact

use of au.com.dius.pact.core.model.annotations.Pact 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", "$.domain", "$.values", "$.values", "$.values[*].key", "$.values[*].value");
    return messagePact;
}
Also used : MessagePact(au.com.dius.pact.core.model.messaging.MessagePact) HashMap(java.util.HashMap) PactDslJsonBody(au.com.dius.pact.consumer.dsl.PactDslJsonBody) Pact(au.com.dius.pact.core.model.annotations.Pact) MessagePact(au.com.dius.pact.core.model.messaging.MessagePact)

Example 4 with Pact

use of au.com.dius.pact.core.model.annotations.Pact 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.core.model.messaging.MessagePact) Pact(au.com.dius.pact.core.model.annotations.Pact) RequestResponsePact(au.com.dius.pact.core.model.RequestResponsePact)

Example 5 with Pact

use of au.com.dius.pact.core.model.annotations.Pact 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.core.model.messaging.MessagePact) Pact(au.com.dius.pact.core.model.annotations.Pact) RequestResponsePact(au.com.dius.pact.core.model.RequestResponsePact)

Aggregations

Pact (au.com.dius.pact.core.model.annotations.Pact)31 MessagePact (au.com.dius.pact.core.model.messaging.MessagePact)21 PactDslJsonBody (au.com.dius.pact.consumer.dsl.PactDslJsonBody)19 HashMap (java.util.HashMap)18 RequestResponsePact (au.com.dius.pact.core.model.RequestResponsePact)14 Method (java.lang.reflect.Method)5 MessagePactBuilder (au.com.dius.pact.consumer.MessagePactBuilder)4 DslPart (au.com.dius.pact.consumer.dsl.DslPart)4 PactDslJsonArray (au.com.dius.pact.consumer.dsl.PactDslJsonArray)3 MatchingRuleGroup (au.com.dius.pact.core.model.matchingrules.MatchingRuleGroup)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 PactDslWithProvider (au.com.dius.pact.consumer.dsl.PactDslWithProvider)2 BasePact (au.com.dius.pact.core.model.BasePact)2 ProviderState (au.com.dius.pact.core.model.ProviderState)2 PactDirectory (au.com.dius.pact.core.model.annotations.PactDirectory)2 PactFolder (au.com.dius.pact.core.model.annotations.PactFolder)2 MatchingRules (au.com.dius.pact.core.model.matchingrules.MatchingRules)2 RegexMatcher (au.com.dius.pact.core.model.matchingrules.RegexMatcher)2 Message (au.com.dius.pact.core.model.messaging.Message)2 PactVerificationResult (au.com.dius.pact.consumer.PactVerificationResult)1