Search in sources :

Example 16 with ExecuteCommandRequest

use of io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldDeployMultipleResources.

@SuppressWarnings("unchecked")
@Test
public void shouldDeployMultipleResources() {
    // given
    stubDeploymentRequest();
    final WorkflowDefinition definition1 = Bpmn.createExecutableWorkflow("model1").startEvent().done();
    final WorkflowDefinition definition2 = Bpmn.createExecutableWorkflow("model2").startEvent().done();
    // when
    clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addWorkflowModel(definition1, "model1.bpmn").addWorkflowModel(definition2, "model2.bpmn").execute();
    // then
    assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
    final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
    final List<Map<String, Object>> resources = (List<Map<String, Object>>) commandRequest.getCommand().get("resources");
    assertThat(resources).hasSize(2);
    assertThat(resources).extracting("resourceName").contains("model1.bpmn", "model2.bpmn");
    assertThat(resources).extracting("resourceType").contains("BPMN_XML", "BPMN_XML");
    assertThat(resources).extracting("resource").contains(Bpmn.convertToString(definition1).getBytes(UTF_8), Bpmn.convertToString(definition2).getBytes(UTF_8));
}
Also used : ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition)

Example 17 with ExecuteCommandRequest

use of io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldDeployResourceAsBytes.

@SuppressWarnings("unchecked")
@Test
public void shouldDeployResourceAsBytes() {
    // given
    stubDeploymentRequest();
    // when
    clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addResourceBytes(WORKFLOW_AS_BYTES, "workflow.bpmn").execute();
    // then
    assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
    final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
    final List<Map<String, Object>> resources = (List<Map<String, Object>>) commandRequest.getCommand().get("resources");
    assertThat(resources).hasSize(1);
    assertThat(resources.get(0)).containsEntry("resource", WORKFLOW_AS_BYTES).containsEntry("resourceName", "workflow.bpmn").containsEntry("resourceType", "BPMN_XML");
}
Also used : ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest)

Example 18 with ExecuteCommandRequest

use of io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldDeployResourceAsStream.

@SuppressWarnings("unchecked")
@Test
public void shouldDeployResourceAsStream() {
    // given
    stubDeploymentRequest();
    // when
    clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addResourceStream(new ByteArrayInputStream(WORKFLOW_AS_BYTES), "workflow.bpmn").execute();
    // then
    assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
    final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
    final List<Map<String, Object>> resources = (List<Map<String, Object>>) commandRequest.getCommand().get("resources");
    assertThat(resources).hasSize(1);
    assertThat(resources.get(0)).containsEntry("resource", WORKFLOW_AS_BYTES).containsEntry("resourceName", "workflow.bpmn").containsEntry("resourceType", "BPMN_XML");
}
Also used : ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 19 with ExecuteCommandRequest

use of io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldDeployResourceFromYamlClasspath.

@SuppressWarnings("unchecked")
@Test
public void shouldDeployResourceFromYamlClasspath() throws Exception {
    // given
    stubDeploymentRequest();
    // when
    clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addResourceFromClasspath("workflows/simple-workflow.yaml").execute();
    // then
    assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
    final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
    final List<Map<String, Object>> resources = (List<Map<String, Object>>) commandRequest.getCommand().get("resources");
    assertThat(resources).hasSize(1);
    assertThat(resources.get(0)).containsKey("resource").containsEntry("resourceName", "workflows/simple-workflow.yaml").containsEntry("resourceType", "YAML_WORKFLOW");
    final byte[] resource = (byte[]) resources.get(0).get("resource");
    final String filePath = getClass().getResource("/workflows/simple-workflow.yaml").toURI().getPath();
    assertThat(new File(filePath)).hasBinaryContent(resource);
}
Also used : ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) File(java.io.File)

Example 20 with ExecuteCommandRequest

use of io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldDeployResourceAsWorkflowModel.

@SuppressWarnings("unchecked")
@Test
public void shouldDeployResourceAsWorkflowModel() {
    // given
    stubDeploymentRequest();
    // when
    clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addWorkflowModel(WORKFLOW_MODEL, "model.bpmn").execute();
    // then
    assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
    final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
    final List<Map<String, Object>> resources = (List<Map<String, Object>>) commandRequest.getCommand().get("resources");
    assertThat(resources).hasSize(1);
    assertThat(resources.get(0)).containsEntry("resource", WORKFLOW_AS_BYTES).containsEntry("resourceName", "model.bpmn").containsEntry("resourceType", "BPMN_XML");
}
Also used : ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest)

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