use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeIT method should_startAnAlreadyCreatedProcess_when_startCreatedProcessIsCalled.
@Test
public void should_startAnAlreadyCreatedProcess_when_startCreatedProcessIsCalled() {
securityUtil.logInAs("garth");
ProcessInstance singleTaskProcessCreated = processRuntime.create(ProcessPayloadBuilder.create().withProcessDefinitionKey(SINGLE_TASK_PROCESS).build());
assertThat(singleTaskProcessCreated.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.CREATED);
Page<Task> tasks = taskRuntime.tasks(PAGEABLE, TaskPayloadBuilder.tasks().withProcessInstanceId(singleTaskProcessCreated.getId()).build());
assertThat(tasks.getTotalItems()).isEqualTo(0);
ProcessInstance singleTaskProcessStarted = processRuntime.startCreatedProcess(singleTaskProcessCreated.getId(), ProcessPayloadBuilder.start().build());
tasks = taskRuntime.tasks(PAGEABLE, TaskPayloadBuilder.tasks().withProcessInstanceId(singleTaskProcessCreated.getId()).build());
assertThat(tasks.getTotalItems()).isEqualTo(1);
assertThat(tasks.getContent().get(0).getName()).isEqualTo("my-task");
assertThat(RuntimeTestConfiguration.createdTasks).contains(tasks.getContent().get(0).getId());
assertThat(singleTaskProcessStarted).isNotNull();
assertThat(singleTaskProcessStarted.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeIT method should_throwAnError_when_ProcessInstanceIsAlreadyStartedOrCompleted.
@Test
public void should_throwAnError_when_ProcessInstanceIsAlreadyStartedOrCompleted() {
ProcessInstance categorizeProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(CATEGORIZE_HUMAN_PROCESS).withVariable("expectedKey", true).withVariable("name", "garth").withVariable("age", 45).withBusinessKey("my business key").build());
assertThat(categorizeProcess.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
Throwable throwable = catchThrowable(() -> processRuntime.startCreatedProcess(categorizeProcess.getId(), new StartProcessPayload()));
assertThat(throwable).isInstanceOf(ActivitiIllegalArgumentException.class).hasMessage("Process instance " + categorizeProcess.getId() + " has already been started");
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNMessageIT method shouldReceiveEventGatewayMessageWithCorrelationKey.
@Test
public void shouldReceiveEventGatewayMessageWithCorrelationKey() {
ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start().withBusinessKey("businessKey").withVariable("correlationKey", "foo").withProcessDefinitionKey(EVENT_GATEWAY_MESSAGE).build());
// when
processRuntime.receive(MessagePayloadBuilder.receive(TEST_MESSAGE).withVariable("key", "value").withCorrelationKey("foo").build());
// then
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_WAITING, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "testMessage", "foo", process.getBusinessKey(), null), Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_RECEIVED, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "testMessage", "foo", process.getBusinessKey(), singletonMap("key", "value")));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNMessageIT method shouldStartProcessByMessage.
@Test
public void shouldStartProcessByMessage() {
// when
ProcessInstance process = processRuntime.start(MessagePayloadBuilder.start(TEST_MESSAGE).withBusinessKey("businessKey").withVariable("key", "value").build());
// then
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_RECEIVED, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "testMessage", null, process.getBusinessKey(), singletonMap("key", "value")));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeBPMNMessageIT method shouldStartProcessByMessageWithMappedPayload.
@Test
public void shouldStartProcessByMessageWithMappedPayload() {
// when
ProcessInstance process = processRuntime.start(MessagePayloadBuilder.start(START_MESSAGE_PAYLOAD).withBusinessKey("businessKey").withVariable("message_variable_name", "value").build());
// then
assertThat(MessageTestConfiguration.messageEvents).isNotEmpty().extracting(BPMNMessageEvent::getEventType, BPMNMessageEvent::getProcessDefinitionId, BPMNMessageEvent::getProcessInstanceId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getMessagePayload().getName(), event -> event.getEntity().getMessagePayload().getCorrelationKey(), event -> event.getEntity().getMessagePayload().getBusinessKey(), event -> event.getEntity().getMessagePayload().getVariables()).contains(Tuple.tuple(BPMNMessageEvent.MessageEvents.MESSAGE_RECEIVED, process.getProcessDefinitionId(), process.getId(), process.getProcessDefinitionId(), process.getId(), "startMessagePayload", null, process.getBusinessKey(), singletonMap("message_variable_name", "value")));
// and
List<VariableInstance> variables = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstanceId(process.getId()).build());
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).contains(tuple("process_variable_name", "value"));
}
Aggregations