Search in sources :

Example 21 with Pact

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

the class V4PactBuilderTest method messageInteraction.

@Pact(consumer = "v4_test_consumer")
V4Pact messageInteraction(PactBuilder builder) {
    PactDslJsonBody body = new PactDslJsonBody();
    body.stringValue("testParam1", "value1");
    body.stringValue("testParam2", "value2");
    Map<String, Object> metadata = new HashMap<>();
    metadata.put("destination", Matchers.regexp("\\w+\\d+", "X001"));
    return builder.usingLegacyMessageDsl().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) V4Pact(au.com.dius.pact.core.model.V4Pact) Pact(au.com.dius.pact.core.model.annotations.Pact)

Example 22 with Pact

use of au.com.dius.pact.core.model.annotations.Pact 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, Object> metadata = new HashMap<>();
    metadata.put("Content-Type", "application/json");
    metadata.put("destination", Matchers.regexp("\\w+\\d+", "X001"));
    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)

Example 23 with Pact

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

the class AsyncMessageTest method createPact2.

@Pact(provider = "test_provider", consumer = "test_consumer_v3")
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("Content-Type", "application/json");
    return builder.given("SomeProviderState2").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)

Example 24 with Pact

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

Example 25 with Pact

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

the class ExampleMessageWithMetadataConsumerTest 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<>();
    metadata.put("metadata1", "metadataValue1");
    metadata.put("metadata2", "metadataValue2");
    return builder.given("SomeProviderState").expectsToReceive("a test message with metadata").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)

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