Class MessageContentsBuilder
-
- All Implemented Interfaces:
public final class MessageContentsBuilder
DSL builder for the message contents part of a V4 message
-
-
Field Summary
Fields Modifier and Type Field Description private MessageContents
contents
-
Constructor Summary
Constructors Constructor Description MessageContentsBuilder(MessageContents contents)
-
Method Summary
Modifier and Type Method Description final MessageContents
getContents()
final Unit
setContents(MessageContents contents)
final MessageContents
build()
final MessageContentsBuilder
withMetadata(Map<String, Object> metadata)
Adds the expected metadata to the message contents final MessageContentsBuilder
withMetadata(Consumer<MetadataBuilder> consumer)
Adds the expected metadata to the message using a builder final MessageContentsBuilder
withContent(DslPart body)
Adds the JSON body as the message content final MessageContentsBuilder
withContent(PactXmlBuilder xmlBuilder)
Adds the XML body as the message content final MessageContentsBuilder
withContent(String payload, String contentType)
Adds the string as the message contents with the given content type. final MessageContentsBuilder
withContent(String payload)
Adds the string as the message contents with the given content type. final MessageContentsBuilder
withContent(ByteArray payload, String contentType)
Sets the contents of the message as a byte array. final MessageContentsBuilder
withContent(ByteArray payload)
Sets the contents of the message as a byte array. final MessageContentsBuilder
withContentsMatchingContentType(String contentType, ByteArray exampleContents)
Sets up a content type matcher to match any payload of the given content type -
-
Method Detail
-
getContents
final MessageContents getContents()
-
setContents
final Unit setContents(MessageContents contents)
-
build
final MessageContents build()
-
withMetadata
final MessageContentsBuilder withMetadata(Map<String, Object> metadata)
Adds the expected metadata to the message contents
-
withMetadata
final MessageContentsBuilder withMetadata(Consumer<MetadataBuilder> consumer)
Adds the expected metadata to the message using a builder
-
withContent
final MessageContentsBuilder withContent(DslPart body)
Adds the JSON body as the message content
-
withContent
final MessageContentsBuilder withContent(PactXmlBuilder xmlBuilder)
Adds the XML body as the message content
-
withContent
@JvmOverloads() final MessageContentsBuilder withContent(String payload, String contentType)
Adds the string as the message contents with the given content type. If the content type is not supplied, it will try to detect it otherwise will default to plain text.
-
withContent
@JvmOverloads() final MessageContentsBuilder withContent(String payload)
Adds the string as the message contents with the given content type. If the content type is not supplied, it will try to detect it otherwise will default to plain text.
-
withContent
@JvmOverloads() final MessageContentsBuilder withContent(ByteArray payload, String contentType)
Sets the contents of the message as a byte array. If the content type is not provided or already set, will default to application/octet-stream.
-
withContent
@JvmOverloads() final MessageContentsBuilder withContent(ByteArray payload)
Sets the contents of the message as a byte array. If the content type is not provided or already set, will default to application/octet-stream.
-
withContentsMatchingContentType
final MessageContentsBuilder withContentsMatchingContentType(String contentType, ByteArray exampleContents)
Sets up a content type matcher to match any payload of the given content type
-
-
-
-