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 Aug 28, 2023
1 parent 1b00f63 commit 2b2055f
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 2b2055f

Please sign in to comment.