From 2b2055f0d9e0d10c2bfe51898d7163e037a772d9 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Mon, 28 Aug 2023 10:40:55 +1000 Subject: [PATCH] chore: Add missing key and pending methods to SynchronousMessagePactBuilder #1707 --- .../dsl/SynchronousMessagePactBuilder.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/SynchronousMessagePactBuilder.kt b/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/SynchronousMessagePactBuilder.kt index 843399dbc..a0dcaf0a9 100644 --- a/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/SynchronousMessagePactBuilder.kt +++ b/consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/SynchronousMessagePactBuilder.kt @@ -103,6 +103,43 @@ class SynchronousMessagePactBuilder @JvmOverloads constructor( return this } + /** + * Marks the interaction as pending. + */ + fun pending(pending: Boolean): SynchronousMessagePactBuilder { + if (messages.isEmpty()) { + throw InvalidPactException("expectsToReceive is required before pending") + } + val message = messages.last() + message.pending = pending + return this + } + + /** + * Adds a text comment to the interaction + */ + fun comment(comment: String): SynchronousMessagePactBuilder { + if (messages.isEmpty()) { + throw InvalidPactException("expectsToReceive is required before comment") + } + val message = messages.last() + message.addTextComment(comment) + return this + } + + /** + * Sets the unique key for the interaction. If this is not set, or is empty, a key will be calculated from the + * contents of the interaction. + */ + fun key(key: String?): SynchronousMessagePactBuilder { + if (messages.isEmpty()) { + throw InvalidPactException("expectsToReceive is required before key") + } + val message = messages.last() + message.key = key + return this; + } + /** * Adds a message expectation to the pact. *