Search in sources :

Example 1 with PROP_WORKFLOW_BPMN_PROCESS_ID

use of io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldCreateDeploymentWithMultipleResourcesAndWorkflows.

@Test
public void shouldCreateDeploymentWithMultipleResourcesAndWorkflows() throws IOException {
    // given
    final WorkflowDefinition singleWorkflow = Bpmn.createExecutableWorkflow("singleProcess").startEvent().done();
    final InputStream multipleWorkflowsResource = getClass().getResourceAsStream("/workflows/collaboration.bpmn");
    final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(bpmnXml(singleWorkflow), "process1.bpmn"), deploymentResource(StreamUtil.read(multipleWorkflowsResource), "collaboration.bpmn"));
    // when
    final ExecuteCommandResponse resp = apiRule.createCmdRequest().partitionId(Protocol.SYSTEM_PARTITION).eventType(EventType.DEPLOYMENT_EVENT).command().put(PROP_STATE, "CREATE").put("topicName", ClientApiRule.DEFAULT_TOPIC_NAME).put("resources", resources).done().sendAndAwait();
    // then
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
    final List<SubscribedEvent> workflowEvents = apiRule.topic().receiveEvents(workflowEvents("CREATED")).limit(3).collect(toList());
    assertThat(workflowEvents).extracting(s -> s.event().get(PROP_WORKFLOW_BPMN_PROCESS_ID)).contains("singleProcess", "process1", "process2");
}
Also used : TestTopicClient.workflowEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowEvents) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) EmbeddedBrokerRule(io.zeebe.broker.test.EmbeddedBrokerRule) Bpmn(io.zeebe.model.bpmn.Bpmn) Protocol(io.zeebe.protocol.Protocol) ArrayList(java.util.ArrayList) ResourceType(io.zeebe.broker.workflow.data.ResourceType) Map(java.util.Map) PROP_WORKFLOW_VERSION(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_VERSION) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) UTF_8(java.nio.charset.StandardCharsets.UTF_8) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) RuleChain(org.junit.rules.RuleChain) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Rule(org.junit.Rule) StreamUtil(io.zeebe.util.StreamUtil) PROP_STATE(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_STATE) EventType(io.zeebe.protocol.clientapi.EventType) PROP_WORKFLOW_BPMN_PROCESS_ID(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID) Files(org.assertj.core.util.Files) Collections(java.util.Collections) InputStream(java.io.InputStream) ClientApiRule(io.zeebe.test.broker.protocol.clientapi.ClientApiRule) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) InputStream(java.io.InputStream) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) HashMap(java.util.HashMap) Map(java.util.Map) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 2 with PROP_WORKFLOW_BPMN_PROCESS_ID

use of io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldCreateDeploymentWithMultipleResources.

@Test
public void shouldCreateDeploymentWithMultipleResources() {
    // given
    final WorkflowDefinition definition1 = Bpmn.createExecutableWorkflow("process1").startEvent().done();
    final WorkflowDefinition definition2 = Bpmn.createExecutableWorkflow("process2").startEvent().done();
    final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(bpmnXml(definition1), "process1.bpmn"), deploymentResource(bpmnXml(definition2), "process2.bpmn"));
    // when
    final ExecuteCommandResponse resp = apiRule.createCmdRequest().partitionId(Protocol.SYSTEM_PARTITION).eventType(EventType.DEPLOYMENT_EVENT).command().put(PROP_STATE, "CREATE").put("topicName", ClientApiRule.DEFAULT_TOPIC_NAME).put("resources", resources).done().sendAndAwait();
    // then
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
    final List<SubscribedEvent> workflowEvents = apiRule.topic().receiveEvents(workflowEvents("CREATED")).limit(2).collect(toList());
    assertThat(workflowEvents).extracting(s -> s.event().get(PROP_WORKFLOW_BPMN_PROCESS_ID)).contains("process1", "process2");
}
Also used : TestTopicClient.workflowEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowEvents) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) EmbeddedBrokerRule(io.zeebe.broker.test.EmbeddedBrokerRule) Bpmn(io.zeebe.model.bpmn.Bpmn) Protocol(io.zeebe.protocol.Protocol) ArrayList(java.util.ArrayList) ResourceType(io.zeebe.broker.workflow.data.ResourceType) Map(java.util.Map) PROP_WORKFLOW_VERSION(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_VERSION) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) UTF_8(java.nio.charset.StandardCharsets.UTF_8) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) RuleChain(org.junit.rules.RuleChain) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Rule(org.junit.Rule) StreamUtil(io.zeebe.util.StreamUtil) PROP_STATE(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_STATE) EventType(io.zeebe.protocol.clientapi.EventType) PROP_WORKFLOW_BPMN_PROCESS_ID(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID) Files(org.assertj.core.util.Files) Collections(java.util.Collections) InputStream(java.io.InputStream) ClientApiRule(io.zeebe.test.broker.protocol.clientapi.ClientApiRule) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) HashMap(java.util.HashMap) Map(java.util.Map) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Example 3 with PROP_WORKFLOW_BPMN_PROCESS_ID

use of io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldCreateDeploymentResourceWithMultipleWorkflows.

@Test
public void shouldCreateDeploymentResourceWithMultipleWorkflows() throws IOException {
    // given
    final InputStream resourceAsStream = getClass().getResourceAsStream("/workflows/collaboration.bpmn");
    // when
    final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, StreamUtil.read(resourceAsStream), ResourceType.BPMN_XML.name(), "collaboration.bpmn");
    // then
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
    final List<SubscribedEvent> workflowEvents = apiRule.topic().receiveEvents(workflowEvents("CREATED")).limit(2).collect(toList());
    assertThat(workflowEvents).extracting(s -> s.event().get(PROP_WORKFLOW_BPMN_PROCESS_ID)).contains("process1", "process2");
}
Also used : TestTopicClient.workflowEvents(io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowEvents) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) EmbeddedBrokerRule(io.zeebe.broker.test.EmbeddedBrokerRule) Bpmn(io.zeebe.model.bpmn.Bpmn) Protocol(io.zeebe.protocol.Protocol) ArrayList(java.util.ArrayList) ResourceType(io.zeebe.broker.workflow.data.ResourceType) Map(java.util.Map) PROP_WORKFLOW_VERSION(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_VERSION) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) UTF_8(java.nio.charset.StandardCharsets.UTF_8) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) RuleChain(org.junit.rules.RuleChain) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Rule(org.junit.Rule) StreamUtil(io.zeebe.util.StreamUtil) PROP_STATE(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_STATE) EventType(io.zeebe.protocol.clientapi.EventType) PROP_WORKFLOW_BPMN_PROCESS_ID(io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID) Files(org.assertj.core.util.Files) Collections(java.util.Collections) InputStream(java.io.InputStream) ClientApiRule(io.zeebe.test.broker.protocol.clientapi.ClientApiRule) ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) InputStream(java.io.InputStream) SubscribedEvent(io.zeebe.test.broker.protocol.clientapi.SubscribedEvent) Test(org.junit.Test)

Aggregations

EmbeddedBrokerRule (io.zeebe.broker.test.EmbeddedBrokerRule)3 ResourceType (io.zeebe.broker.workflow.data.ResourceType)3 PROP_STATE (io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_STATE)3 PROP_WORKFLOW_BPMN_PROCESS_ID (io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_BPMN_PROCESS_ID)3 PROP_WORKFLOW_VERSION (io.zeebe.broker.workflow.data.WorkflowInstanceEvent.PROP_WORKFLOW_VERSION)3 Bpmn (io.zeebe.model.bpmn.Bpmn)3 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)3 Protocol (io.zeebe.protocol.Protocol)3 EventType (io.zeebe.protocol.clientapi.EventType)3 ClientApiRule (io.zeebe.test.broker.protocol.clientapi.ClientApiRule)3 ExecuteCommandResponse (io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)3 SubscribedEvent (io.zeebe.test.broker.protocol.clientapi.SubscribedEvent)3 TestTopicClient.workflowEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowEvents)3 StreamUtil (io.zeebe.util.StreamUtil)3 File (java.io.File)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3