Search in sources :

Example 41 with ExecuteCommandRequest

use of io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest 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)));
}
Also used : TasksClient(io.zeebe.client.TasksClient) TaskEvent(io.zeebe.client.event.TaskEvent) Events(io.zeebe.client.util.Events) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Assertions.entry(org.assertj.core.api.Assertions.entry) StandardCharsets(java.nio.charset.StandardCharsets) StubBrokerRule(io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule) RuleChain(org.junit.rules.RuleChain) Rule(org.junit.Rule) ClientRule(io.zeebe.client.util.ClientRule) ByteArrayInputStream(java.io.ByteArrayInputStream) EventType(io.zeebe.protocol.clientapi.EventType) ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) ExpectedException(org.junit.rules.ExpectedException) MsgPackConverter(io.zeebe.client.impl.data.MsgPackConverter) Before(org.junit.Before) TaskEventImpl(io.zeebe.client.event.impl.TaskEventImpl) ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) TaskEventImpl(io.zeebe.client.event.impl.TaskEventImpl) Test(org.junit.Test)

Aggregations

ExecuteCommandRequest (io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest)41 Test (org.junit.Test)30 ClientRule (io.zeebe.client.util.ClientRule)15 StubBrokerRule (io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule)15 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)15 ExpectedException (org.junit.rules.ExpectedException)15 RuleChain (org.junit.rules.RuleChain)15 EventType (io.zeebe.protocol.clientapi.EventType)14 Rule (org.junit.Rule)14 Assertions.entry (org.assertj.core.api.Assertions.entry)12 TaskEvent (io.zeebe.client.event.TaskEvent)11 Before (org.junit.Before)11 ZeebeClient (io.zeebe.client.ZeebeClient)10 TasksClient (io.zeebe.client.TasksClient)9 MsgPackConverter (io.zeebe.client.impl.data.MsgPackConverter)9 ZeebeClientImpl (io.zeebe.client.impl.ZeebeClientImpl)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)6 ControlMessageType (io.zeebe.protocol.clientapi.ControlMessageType)6 ErrorCode (io.zeebe.protocol.clientapi.ErrorCode)6