@Test public void shouldRejectDeploymentIfNotValidDesignTimeAspect() throws Exception { // given final Path path = Paths.get(getClass().getResource("/workflows/invalid_process.bpmn").toURI()); final byte[] resource = Files.readAllBytes(path); // when final ExecuteCommandResponse resp = apiRule.partitionClient().deployWithResponse(resource); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); assertThat(resp.getRejectionReason()).contains("ERROR: Must have at least one start event"); }
@Test public void shouldRejectDeploymentIfNotValidDesignTimeAspect() throws Exception { // given final Path path = Paths.get(getClass().getResource("/workflows/invalid_process.bpmn").toURI()); final byte[] resource = Files.readAllBytes(path); // when final ExecuteCommandResponse resp = apiRule.partitionClient().deployWithResponse(resource); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); assertThat(resp.getRejectionReason()).contains("ERROR: Must have at least one start event"); }
@Test public void shouldRejectDeploymentIfNotParsable() { // when final ExecuteCommandResponse resp = apiRule .partitionClient() .deployWithResponse( "not a workflow".getBytes(UTF_8), ResourceType.BPMN_XML.name(), "invalid.bpmn"); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); }
@Test public void shouldRejectDeploymentIfNotValidRuntimeAspect() throws Exception { // given final Path path = Paths.get(getClass().getResource("/workflows/invalid_process_condition.bpmn").toURI()); final byte[] resource = Files.readAllBytes(path); // when final ExecuteCommandResponse resp = apiRule.partitionClient().deployWithResponse(resource); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); assertThat(resp.getRejectionReason()) .contains("Element: flow2 > conditionExpression") .contains("ERROR: Condition expression is invalid"); }
@Test public void shouldRejectDeploymentIfNotParsable() { // when final ExecuteCommandResponse resp = apiRule .partitionClient() .deployWithResponse( "not a workflow".getBytes(UTF_8), ResourceType.BPMN_XML.name(), "invalid.bpmn"); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); }
@Test public void shouldRejectDeploymentIfNotValidRuntimeAspect() throws Exception { // given final Path path = Paths.get(getClass().getResource("/workflows/invalid_process_condition.bpmn").toURI()); final byte[] resource = Files.readAllBytes(path); // when final ExecuteCommandResponse resp = apiRule.partitionClient().deployWithResponse(resource); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); assertThat(resp.getRejectionReason()) .contains("Element: flow2 > conditionExpression") .contains("ERROR: Condition expression is invalid"); }
@Test public void shouldRejectDeploymentIfOneResourceIsNotValid() throws Exception { // given final Path path1 = Paths.get(getClass().getResource("/workflows/invalid_process.bpmn").toURI()); final Path path2 = Paths.get(getClass().getResource("/workflows/collaboration.bpmn").toURI()); final byte[] resource1 = Files.readAllBytes(path1); final byte[] resource2 = Files.readAllBytes(path2); final List<Map<String, Object>> resources = Arrays.asList( deploymentResource(resource1, "process1.bpmn"), deploymentResource(resource2, "process2.bpmn")); // when final ExecuteCommandResponse resp = apiRule .createCmdRequest() .partitionId(DEPLOYMENT_PARTITION) .type(ValueType.DEPLOYMENT, DeploymentIntent.CREATE) .command() .put("resources", resources) .done() .sendAndAwait(); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); }
@Test public void shouldRejectDeploymentIfOneResourceIsNotValid() throws Exception { // given final Path path = Paths.get(getClass().getResource("/workflows/invalid_process.bpmn").toURI()); final byte[] resource = Files.readAllBytes(path); final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(resource, "process2.bpmn")); // when final ExecuteCommandResponse resp = apiRule .createCmdRequest() .partitionId(DEPLOYMENT_PARTITION) .type(ValueType.DEPLOYMENT, DeploymentIntent.CREATE) .command() .put("resources", resources) .done() .sendAndAwait(); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); }
@Test public void shouldRejectDeploymentIfNoResources() { // when final ExecuteCommandResponse resp = apiRule .createCmdRequest() .partitionId(DEPLOYMENT_PARTITION) .type(ValueType.DEPLOYMENT, DeploymentIntent.CREATE) .command() .put("resources", Collections.emptyList()) .done() .sendAndAwait(); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); }
@Test public void shouldRejectDeploymentIfNoResources() { // when final ExecuteCommandResponse resp = apiRule .createCmdRequest() .partitionId(DEPLOYMENT_PARTITION) .type(ValueType.DEPLOYMENT, DeploymentIntent.CREATE) .command() .put("resources", Collections.emptyList()) .done() .sendAndAwait(); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATE); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.INVALID_ARGUMENT); }
@Test public void shouldRejectWorkflowInstanceCreation() { // when final ExecuteCommandResponse resp = apiRule .createCmdRequest() .type(ValueType.WORKFLOW_INSTANCE, WorkflowInstanceIntent.CREATE) .command() .put(PROP_WORKFLOW_BPMN_PROCESS_ID, "process") .done() .sendAndAwait(); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getPartitionId()).isEqualTo(apiRule.getDefaultPartitionId()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); assertThat(resp.getValue()).containsEntry(PROP_WORKFLOW_BPMN_PROCESS_ID, "process"); }
@Test public void shouldRejectWorkflowInstanceCreation() { // when final ExecuteCommandResponse resp = apiRule .createCmdRequest() .type(ValueType.WORKFLOW_INSTANCE, WorkflowInstanceIntent.CREATE) .command() .put(PROP_WORKFLOW_BPMN_PROCESS_ID, "process") .done() .sendAndAwait(); // then assertThat(resp.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(resp.getPartitionId()).isEqualTo(apiRule.getDefaultPartitionId()); assertThat(resp.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(resp.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); assertThat(resp.getValue()).containsEntry(PROP_WORKFLOW_BPMN_PROCESS_ID, "process"); }
@Test public void shouldCreateTaskWhenServiceTaskIsActivated() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("foo", t -> t.zeebeTaskType("bar").zeebeTaskRetries(5)) .endEvent() .done()); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<WorkflowInstanceRecordValue> activityActivated = testClient.receiveElementInState("foo", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final Record<JobRecordValue> createJobCmd = testClient.receiveFirstJobCommand(JobIntent.CREATE); assertThat(createJobCmd.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(createJobCmd.getSourceRecordPosition()).isEqualTo(activityActivated.getPosition()); assertJobRecord(createJobCmd); }
@Test public void shouldCreateTaskWhenServiceTaskIsActivated() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("foo", t -> t.zeebeTaskType("bar").zeebeTaskRetries(5)) .endEvent() .done()); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<WorkflowInstanceRecordValue> activityActivated = testClient.receiveElementInState("foo", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final Record<JobRecordValue> createJobCmd = testClient.receiveFirstJobCommand(JobIntent.CREATE); assertThat(createJobCmd.getKey()).isEqualTo(ExecuteCommandResponseDecoder.keyNullValue()); assertThat(createJobCmd.getSourceRecordPosition()).isEqualTo(activityActivated.getPosition()); assertJobRecord(createJobCmd); }