Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vars to ThrowError #583

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Client.UnitTests/PublishMessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ public class PublishMessageTest : BaseZeebeTest
public async Task ShouldSendRequestAsExpected()
{
// given
const string variables = "{\"foo\":23}";
var expectedRequest = new PublishMessageRequest
{
CorrelationKey = "p-1",
Name = "messageName"
Name = "messageName",
Variables = variables
};

// when
await ZeebeClient
.NewPublishMessageCommand()
.MessageName("messageName")
.CorrelationKey("p-1")
.Variables(variables)
.Send();

// then
Expand Down
3 changes: 3 additions & 0 deletions Client.UnitTests/ThrowErrorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ public async Task ShouldSendRequestAsExpected()
const string errorCode = "code 13";
const string errorMessage = "This is a business error!";
const int jobKey = 255;
const string variables = "{\"foo\":23}";
var expectedRequest = new ThrowErrorRequest
{
JobKey = jobKey,
ErrorCode = errorCode,
ErrorMessage = errorMessage,
Variables = variables
};

// when
await ZeebeClient.NewThrowErrorCommand(jobKey)
.ErrorCode("code 13")
.ErrorMessage("This is a business error!")
.Variables(variables)
.Send();

// then
Expand Down
8 changes: 5 additions & 3 deletions Client/Api/Commands/IPublishMessageCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public interface IPublishMessageCommandStep3 : IFinalCommandWithRetryStep<IPubli
///
/// <para>If the duration is zero or negative then the message can only be correlated to open
/// subscriptions (e.g. to an entered message catch event).
///
/// </para>
/// </summary>
///
/// <param name="timeToLive">the time-to-live of the message</param>
/// <returns>the builder for this command. Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send
/// it to the broker.</returns>
/// <returns>
/// the builder for this command. Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send
/// it to the broker.
/// </returns>
IPublishMessageCommandStep3 TimeToLive(TimeSpan timeToLive);

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions Client/Api/Commands/IThrowErrorCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ public interface IThrowErrorCommandStep2 : IFinalCommandWithRetryStep<IThrowErro
/// Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send it to the broker.
/// </returns>
IThrowErrorCommandStep2 ErrorMessage(string errorMessage);

/// <summary>
/// Set the variables to send the error with.
/// </summary>
/// <param name="variables">the variables (JSON) as String.</param>
/// <returns>the builder for this command. Call <see cref="IFinalCommandWithRetryStep{T}.Send"/> to complete the command and send it
/// to the broker.</returns>
IThrowErrorCommandStep2 Variables(string variables);
}
}
6 changes: 6 additions & 0 deletions Client/Impl/Commands/ThrowErrorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public IThrowErrorCommandStep2 ErrorMessage(string errorMessage)
return this;
}

public IThrowErrorCommandStep2 Variables(string variables)
{
request.Variables = variables;
return this;
}

public async Task<IThrowErrorResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
{
var asyncReply = gatewayClient.ThrowErrorAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);
Expand Down
Loading