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));
}
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");
}
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");
}
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);
}
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");
}
Aggregations