Package au.com.dius.pact.consumer
Class MessagePactBuilder
-
- All Implemented Interfaces:
public final class MessagePactBuilderPACT DSL builder for v3 specification messages or v4 asynchronous messages
-
-
Constructor Summary
Constructors Constructor Description MessagePactBuilder(PactSpecVersion specVersion)MessagePactBuilder(Consumer consumer, Provider provider, List<ProviderState> providerStates, List<V4Interaction.AsynchronousMessage> messages, PactSpecVersion specVersion)MessagePactBuilder(Consumer consumer, Provider provider, List<ProviderState> providerStates, List<V4Interaction.AsynchronousMessage> messages)MessagePactBuilder(Consumer consumer, Provider provider, List<ProviderState> providerStates)MessagePactBuilder(Consumer consumer, Provider provider)MessagePactBuilder(Consumer consumer)MessagePactBuilder()
-
Method Summary
Modifier and Type Method Description final MessagePactBuilderconsumer(String consumer)Name the consumer of the pact final MessagePactBuilderhasPactWith(String provider)Name the provider that the consumer has a pact with. final MessagePactBuildergiven(String providerState)Sets the provider state. final MessagePactBuildergiven(String providerState, Map<String, Object> params)Sets the provider state. final MessagePactBuildergiven(ProviderState providerState)Sets the provider state. final MessagePactBuilderexpectsToReceive(String description)Adds a message expectation in the pact. final MessagePactBuilderwithMetadata(Map<String, Object> metadata)Adds the expected metadata to the message final MessagePactBuilderwithMetadata(Consumer<MetadataBuilder> consumer)Adds the expected metadata to the message using a builder final MessagePactBuilderwithContent(DslPart body)Adds the JSON body as the message content final MessagePactBuilderwithContent(PactXmlBuilder xmlBuilder)Adds the XML body as the message content final MessagePactBuilderwithContent(String contents, String contentType)Adds the text as the message contents final MessagePactBuilderwithContent(String contents)Adds the text as the message contents final MessagePactBuilderwithContent(JSONObject json)Adds the JSON body as the message content final <P extends Pact> PtoPact(Class<P> pactClass)Terminates the DSL and builds a pact to represent the interactions final <P extends Pact> PtoPact()Convert this builder into a Pact -
-
Constructor Detail
-
MessagePactBuilder
MessagePactBuilder(PactSpecVersion specVersion)
-
MessagePactBuilder
MessagePactBuilder(Consumer consumer, Provider provider, List<ProviderState> providerStates, List<V4Interaction.AsynchronousMessage> messages, PactSpecVersion specVersion)
-
MessagePactBuilder
MessagePactBuilder(Consumer consumer, Provider provider, List<ProviderState> providerStates, List<V4Interaction.AsynchronousMessage> messages)
-
MessagePactBuilder
MessagePactBuilder(Consumer consumer, Provider provider, List<ProviderState> providerStates)
-
MessagePactBuilder
MessagePactBuilder(Consumer consumer, Provider provider)
-
MessagePactBuilder
MessagePactBuilder(Consumer consumer)
-
MessagePactBuilder
MessagePactBuilder()
-
-
Method Detail
-
consumer
final MessagePactBuilder consumer(String consumer)
Name the consumer of the pact
- Parameters:
consumer- Consumer name
-
hasPactWith
final MessagePactBuilder hasPactWith(String provider)
Name the provider that the consumer has a pact with.
- Parameters:
provider- provider name
-
given
final MessagePactBuilder given(String providerState)
Sets the provider state.
- Parameters:
providerState- description of the provider state
-
given
final MessagePactBuilder given(String providerState, Map<String, Object> params)
Sets the provider state.
- Parameters:
providerState- description of the provider stateparams- key/value pairs to describe state
-
given
final MessagePactBuilder given(ProviderState providerState)
Sets the provider state.
- Parameters:
providerState- state of the provider
-
expectsToReceive
final MessagePactBuilder expectsToReceive(String description)
Adds a message expectation in the pact.
- Parameters:
description- message description.
-
withMetadata
final MessagePactBuilder withMetadata(Map<String, Object> metadata)
Adds the expected metadata to the message
-
withMetadata
final MessagePactBuilder withMetadata(Consumer<MetadataBuilder> consumer)
Adds the expected metadata to the message using a builder
-
withContent
final MessagePactBuilder withContent(DslPart body)
Adds the JSON body as the message content
-
withContent
final MessagePactBuilder withContent(PactXmlBuilder xmlBuilder)
Adds the XML body as the message content
-
withContent
@JvmOverloads() final MessagePactBuilder withContent(String contents, String contentType)
Adds the text as the message contents
-
withContent
@JvmOverloads() final MessagePactBuilder withContent(String contents)
Adds the text as the message contents
-
withContent
final MessagePactBuilder withContent(JSONObject json)
Adds the JSON body as the message content
-
toPact
final <P extends Pact> P toPact(Class<P> pactClass)
Terminates the DSL and builds a pact to represent the interactions
-
-
-
-