Skip to content

Commit

Permalink
chore: Add missing key and pending methods to SynchronousMessagePactB…
Browse files Browse the repository at this point in the history
…uilder #1707
  • Loading branch information
rholshausen committed Apr 22, 2024
1 parent a1bf519 commit 45e4a9c
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 45e4a9c

Please sign in to comment.