Search in sources :

Example 16 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldRejectDeploymentIfOneResourceIsNotValid.

@Test
public void shouldRejectDeploymentIfOneResourceIsNotValid() {
    // given
    final WorkflowDefinition invalidDefinition = Bpmn.createExecutableWorkflow("process").done();
    final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(bpmnXml(WORKFLOW), "process1.bpmn"), deploymentResource(bpmnXml(invalidDefinition), "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.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
    assertThat((String) resp.getEvent().get("errorMessage")).contains("Resource 'process2.bpmn':").contains("The process must contain at least one none start event.");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 17 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldRejectDeploymentIfConditionIsInvalid.

@Test
public void shouldRejectDeploymentIfConditionIsInvalid() {
    final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("workflow").startEvent().exclusiveGateway().sequenceFlow(s -> s.condition("foobar")).endEvent().sequenceFlow(s -> s.defaultFlow()).endEvent().done();
    // when
    final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
    // then
    assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
    assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
    assertThat((String) resp.getEvent().get("errorMessage")).contains("The condition 'foobar' is not valid");
}
Also used : ExecuteCommandResponse(io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) Test(org.junit.Test)

Example 18 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.

the class WorkflowTaskIOMappingTest method shouldNotDeployIfOutputMappingIsNotValid.

@Test
public void shouldNotDeployIfOutputMappingIsNotValid() throws Throwable {
    // given
    final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").output(NODE_STRING_KEY, "")).endEvent().done();
    final ExecuteCommandResponse response = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
    assertThat(response.getEvent().get(PROP_STATE)).isEqualTo("REJECTED");
}
Also used : WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition)

Example 19 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.

the class WorkflowTaskIOMappingTest method shouldNotMapPayloadToWorkflowIfOutMappingMapsRootAndOtherPath.

@Test
public void shouldNotMapPayloadToWorkflowIfOutMappingMapsRootAndOtherPath() throws Throwable {
    // given
    final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").output(NODE_STRING_PATH, NODE_ROOT_PATH).output(NODE_JSON_OBJECT_PATH, NODE_JSON_OBJECT_PATH)).endEvent().done();
    // when
    final ExecuteCommandResponse response = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
    // then
    assertThat(response.getEvent().get(PROP_STATE)).isEqualTo("REJECTED");
    assertThat(response.getEvent().get(PROP_ERRO_MSG).toString()).contains("Target mapping: root mapping is not allowed because it would override other mapping.");
}
Also used : WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition)

Example 20 with WorkflowDefinition

use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.

the class WorkflowTaskIOMappingTest method shouldNotDeployIfInputMappingIsNotValid.

@Test
public void shouldNotDeployIfInputMappingIsNotValid() throws Throwable {
    // given
    final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("service", t -> t.taskType("external").input("$.*", NODE_ROOT_PATH)).endEvent().done();
    // when
    final ExecuteCommandResponse response = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
    // then
    assertThat(response.getEvent().get(PROP_STATE)).isEqualTo("REJECTED");
    assertThat(response.getEvent().get(PROP_ERRO_MSG).toString()).contains("Source mapping: JSON path '$.*' contains prohibited expression");
}
Also used : WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition)

Aggregations

WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)27 Bpmn (io.zeebe.model.bpmn.Bpmn)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 RuleChain (org.junit.rules.RuleChain)8 EmbeddedBrokerRule (io.zeebe.broker.test.EmbeddedBrokerRule)7 EventType (io.zeebe.protocol.clientapi.EventType)7 ResourceType (io.zeebe.broker.workflow.data.ResourceType)6 Protocol (io.zeebe.protocol.Protocol)6 ExecuteCommandResponse (io.zeebe.test.broker.protocol.clientapi.ExecuteCommandResponse)6 File (java.io.File)6 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)6 Files (org.assertj.core.util.Files)6 Test (org.junit.Test)6 org.junit (org.junit)5 WorkflowInstanceEvent (io.zeebe.broker.workflow.data.WorkflowInstanceEvent)4 TestTopicClient.taskEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.taskEvents)4 TestTopicClient.workflowInstanceEvents (io.zeebe.test.broker.protocol.clientapi.TestTopicClient.workflowInstanceEvents)4 MsgPackUtil.asMsgPack (io.zeebe.test.util.MsgPackUtil.asMsgPack)4 WorkflowInstanceEvent (io.zeebe.client.event.WorkflowInstanceEvent)3 io.zeebe.test.broker.protocol.clientapi (io.zeebe.test.broker.protocol.clientapi)3