Skip to content

Commit

Permalink
fix: allow sending variables with a message
Browse files Browse the repository at this point in the history
In our testing Utilities class we had some helper methods to send variables. These methods did not allow for sending message with variables. Now they do.

Note: our testing Utilities are not exposed to users. There are no backwards compatibility concerns here.
  • Loading branch information
remcowesterhoud committed Mar 30, 2022
1 parent fd11b2e commit 6b523d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ void testHasExpired() throws InterruptedException, TimeoutException {
// when
final PublishMessageResponse response =
Utilities.sendMessage(
engine, client, ProcessPackMessageEvent.MESSAGE_NAME, CORRELATION_KEY, timeToLive);
engine,
client,
ProcessPackMessageEvent.MESSAGE_NAME,
CORRELATION_KEY,
timeToLive,
Collections.emptyMap());
Utilities.increaseTime(engine, timeToLive.plusMinutes(1));

// then
Expand Down Expand Up @@ -285,7 +290,12 @@ void testHasNotExpiredFailure() throws InterruptedException, TimeoutException {
// when
final PublishMessageResponse response =
Utilities.sendMessage(
engine, client, ProcessPackMessageEvent.MESSAGE_NAME, CORRELATION_KEY, timeToLive);
engine,
client,
ProcessPackMessageEvent.MESSAGE_NAME,
CORRELATION_KEY,
timeToLive,
Collections.emptyMap());
Utilities.increaseTime(engine, timeToLive.plusMinutes(1));

// then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.camunda.zeebe.protocol.record.intent.JobIntent;
import io.camunda.zeebe.protocol.record.value.JobRecordValue;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -122,22 +123,36 @@ public static PublishMessageResponse sendMessage(
final String messageName,
final String correlationKey)
throws InterruptedException, TimeoutException {
return sendMessage(engine, client, messageName, correlationKey, Duration.ofMinutes(1));
return sendMessage(
engine, client, messageName, correlationKey, Duration.ofMinutes(1), Collections.emptyMap());
}

public static PublishMessageResponse sendMessage(
final ZeebeTestEngine engine,
final ZeebeClient client,
final String messageName,
final String correlationKey,
final Duration timeToLive)
final Map<String, Object> variables)
throws InterruptedException, TimeoutException {
return sendMessage(
engine, client, messageName, correlationKey, Duration.ofMinutes(1), variables);
}

public static PublishMessageResponse sendMessage(
final ZeebeTestEngine engine,
final ZeebeClient client,
final String messageName,
final String correlationKey,
final Duration timeToLive,
final Map<String, Object> variables)
throws InterruptedException, TimeoutException {
final PublishMessageResponse response =
client
.newPublishMessageCommand()
.messageName(messageName)
.correlationKey(correlationKey)
.timeToLive(timeToLive)
.variables(variables)
.send()
.join();
waitForIdleState(engine, Duration.ofSeconds(1));
Expand Down

0 comments on commit 6b523d0

Please sign in to comment.