Skip to content

Commit 2b2055f

Browse files
committedAug 28, 2023
chore: Add missing key and pending methods to SynchronousMessagePactBuilder #1707
1 parent 1b00f63 commit 2b2055f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎consumer/src/main/kotlin/au/com/dius/pact/consumer/dsl/SynchronousMessagePactBuilder.kt

+37
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,43 @@ class SynchronousMessagePactBuilder @JvmOverloads constructor(
103103
return this
104104
}
105105

106+
/**
107+
* Marks the interaction as pending.
108+
*/
109+
fun pending(pending: Boolean): SynchronousMessagePactBuilder {
110+
if (messages.isEmpty()) {
111+
throw InvalidPactException("expectsToReceive is required before pending")
112+
}
113+
val message = messages.last()
114+
message.pending = pending
115+
return this
116+
}
117+
118+
/**
119+
* Adds a text comment to the interaction
120+
*/
121+
fun comment(comment: String): SynchronousMessagePactBuilder {
122+
if (messages.isEmpty()) {
123+
throw InvalidPactException("expectsToReceive is required before comment")
124+
}
125+
val message = messages.last()
126+
message.addTextComment(comment)
127+
return this
128+
}
129+
130+
/**
131+
* Sets the unique key for the interaction. If this is not set, or is empty, a key will be calculated from the
132+
* contents of the interaction.
133+
*/
134+
fun key(key: String?): SynchronousMessagePactBuilder {
135+
if (messages.isEmpty()) {
136+
throw InvalidPactException("expectsToReceive is required before key")
137+
}
138+
val message = messages.last()
139+
message.key = key
140+
return this;
141+
}
142+
106143
/**
107144
* Adds a message expectation to the pact.
108145
*

0 commit comments

Comments
 (0)
Please sign in to comment.