@Test public void shouldRejectUpdateForNonExistingWorkflowInstance() { // when final ExecuteCommandResponse response = updatePayload(-1L, MSGPACK_PAYLOAD); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); final Record<WorkflowInstanceRecordValue> rejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.UPDATE_PAYLOAD) .getFirst(); assertThat(rejection).isNotNull(); }
@Test public void shouldRejectUpdateForNonExistingWorkflowInstance() { // when final ExecuteCommandResponse response = updatePayload(-1L, MSGPACK_PAYLOAD); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); final Record<WorkflowInstanceRecordValue> rejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.UPDATE_PAYLOAD) .getFirst(); assertThat(rejection).isNotNull(); }
@Test public void shouldRejectCancelNonExistingWorkflowInstance() { // when final ExecuteCommandResponse response = cancelWorkflowInstance(-1L); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); assertThat(response.getRejectionReason()) .isEqualTo( "Expected to cancel a workflow instance with key '-1', but no such workflow was found"); final Record<WorkflowInstanceRecordValue> cancelCommand = testClient.receiveFirstWorkflowInstanceCommand(CANCEL); final Record<WorkflowInstanceRecordValue> cancelRejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.CANCEL) .getFirst(); assertThat(cancelRejection).isNotNull(); assertThat(cancelRejection.getSourceRecordPosition()).isEqualTo(cancelCommand.getPosition()); }
@Test public void shouldRejectCancelNonExistingWorkflowInstance() { // when final ExecuteCommandResponse response = cancelWorkflowInstance(-1L); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); assertThat(response.getRejectionReason()) .isEqualTo( "Expected to cancel a workflow instance with key '-1', but no such workflow was found"); final Record<WorkflowInstanceRecordValue> cancelCommand = testClient.receiveFirstWorkflowInstanceCommand(CANCEL); final Record<WorkflowInstanceRecordValue> cancelRejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.CANCEL) .getFirst(); assertThat(cancelRejection).isNotNull(); assertThat(cancelRejection.getSourceRecordPosition()).isEqualTo(cancelCommand.getPosition()); }
@Test public void shouldRejectUpdateForCompletedWorkflowInstance() { // given testClient.deploy(WORKFLOW); testClient.createWorkflowInstance("process"); final Record<WorkflowInstanceRecordValue> activityInstanceEvent = waitForActivityActivatedEvent(); testClient.completeJobOfType("task-1", MSGPACK_PAYLOAD); waitForActivityCompletedEvent(); testClient.completeJobOfType("task-2"); testClient.receiveElementInState("process", WorkflowInstanceIntent.ELEMENT_COMPLETED); // when final ExecuteCommandResponse response = updatePayload(activityInstanceEvent.getKey(), MSGPACK_PAYLOAD); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); final Record<WorkflowInstanceRecordValue> rejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.UPDATE_PAYLOAD) .getFirst(); assertThat(rejection).isNotNull(); }
@Test public void shouldRejectUpdateForCompletedWorkflowInstance() { // given testClient.deploy(WORKFLOW); testClient.createWorkflowInstance("process"); final Record<WorkflowInstanceRecordValue> activityInstanceEvent = waitForActivityActivatedEvent(); testClient.completeJobOfType("task-1", MSGPACK_PAYLOAD); waitForActivityCompletedEvent(); testClient.completeJobOfType("task-2"); testClient.receiveElementInState("process", WorkflowInstanceIntent.ELEMENT_COMPLETED); // when final ExecuteCommandResponse response = updatePayload(activityInstanceEvent.getKey(), MSGPACK_PAYLOAD); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); final Record<WorkflowInstanceRecordValue> rejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.UPDATE_PAYLOAD) .getFirst(); assertThat(rejection).isNotNull(); }
@Test public void shouldRejectCancelCompletedWorkflowInstance() { // given testClient.deploy(Bpmn.createExecutableProcess(PROCESS_ID).startEvent().endEvent().done()); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); testClient.receiveElementInState(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETED); // when final ExecuteCommandResponse response = cancelWorkflowInstance(workflowInstanceKey); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); assertThat(response.getRejectionReason()) .isEqualTo( "Expected to cancel a workflow instance with key '" + workflowInstanceKey + "', but no such workflow was found"); final Record<WorkflowInstanceRecordValue> cancelCommand = testClient.receiveFirstWorkflowInstanceCommand(CANCEL); final Record<WorkflowInstanceRecordValue> cancelRejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.CANCEL) .getFirst(); assertThat(cancelRejection).isNotNull(); assertThat(cancelRejection.getSourceRecordPosition()).isEqualTo(cancelCommand.getPosition()); }
@Test public void shouldRejectCancelCompletedWorkflowInstance() { // given testClient.deploy(Bpmn.createExecutableProcess(PROCESS_ID).startEvent().endEvent().done()); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); testClient.receiveElementInState(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETED); // when final ExecuteCommandResponse response = cancelWorkflowInstance(workflowInstanceKey); // then assertThat(response.getRecordType()).isEqualTo(RecordType.COMMAND_REJECTION); assertThat(response.getRejectionType()).isEqualTo(RejectionType.NOT_FOUND); assertThat(response.getRejectionReason()) .isEqualTo( "Expected to cancel a workflow instance with key '" + workflowInstanceKey + "', but no such workflow was found"); final Record<WorkflowInstanceRecordValue> cancelCommand = testClient.receiveFirstWorkflowInstanceCommand(CANCEL); final Record<WorkflowInstanceRecordValue> cancelRejection = testClient .receiveWorkflowInstances() .onlyCommandRejections() .withIntent(WorkflowInstanceIntent.CANCEL) .getFirst(); assertThat(cancelRejection).isNotNull(); assertThat(cancelRejection.getSourceRecordPosition()).isEqualTo(cancelCommand.getPosition()); }