use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class CompleteTaskTest method shouldThrowExceptionOnRejection.
@Test
public void shouldThrowExceptionOnRejection() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
brokerRule.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").respondWith().key(r -> r.key()).event().allOf((r) -> r.getCommand()).put("state", "COMPLETE_REJECTED").done().register();
final String updatedPayload = "{\"fruit\":\"cherry\"}";
// then
exception.expect(ClientCommandRejectedException.class);
exception.expectMessage("Command for event with key 79 was rejected by broker (COMPLETE_REJECTED)");
// when
clientRule.tasks().complete(baseEvent).payload(updatedPayload).execute();
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class CompleteTaskTest method shouldClearPayload.
@Test
public void shouldClearPayload() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
brokerRule.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").respondWith().key(123).event().allOf((r) -> r.getCommand()).put("state", "COMPLETED").done().register();
// when
clientRule.tasks().complete(baseEvent).withoutPayload().execute();
// then
final ExecuteCommandRequest request = brokerRule.getReceivedCommandRequests().get(0);
assertThat(request.getCommand()).doesNotContainKey("payload");
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class CompleteTaskTest method shouldSetPayloadAsStream.
@Test
public void shouldSetPayloadAsStream() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
brokerRule.onExecuteCommandRequest(EventType.TASK_EVENT, "COMPLETE").respondWith().key(123).event().allOf((r) -> r.getCommand()).put("state", "COMPLETED").done().register();
final String updatedPayload = "{\"fruit\":\"cherry\"}";
final ByteArrayInputStream inStream = new ByteArrayInputStream(updatedPayload.getBytes(StandardCharsets.UTF_8));
// when
clientRule.tasks().complete(baseEvent).payload(inStream).execute();
// then
final ExecuteCommandRequest request = brokerRule.getReceivedCommandRequests().get(0);
assertThat(request.getCommand()).contains(entry("payload", converter.convertToMsgPack(updatedPayload)));
}
use of io.zeebe.client.event.impl.TaskEventImpl in project zeebe by zeebe-io.
the class FailTaskTest method shouldThrowExceptionOnRejection.
@Test
public void shouldThrowExceptionOnRejection() {
// given
final TaskEventImpl baseEvent = Events.exampleTask();
brokerRule.onExecuteCommandRequest(EventType.TASK_EVENT, "FAIL").respondWith().key((r) -> r.key()).event().allOf((r) -> r.getCommand()).put("state", "FAIL_REJECTED").done().register();
// then
exception.expect(ClientCommandRejectedException.class);
exception.expectMessage("Command for event with key 79 was rejected by broker (FAIL_REJECTED)");
// when
clientRule.tasks().fail(baseEvent).retries(5).execute();
}
Aggregations