use of org.activiti.api.process.model.payloads.StartProcessPayload in project Activiti by Activiti.
the class ProcessRuntimeImplTest method should_throwAndException_whenProcessIdDoesNotExists.
@Test
public void should_throwAndException_whenProcessIdDoesNotExists() {
// given
String processInstanceId = "process-instance-id";
ProcessInstanceQuery processQuery = mock(ProcessInstanceQuery.class);
doReturn(processQuery).when(processQuery).processInstanceId(processInstanceId);
doReturn(processQuery).when(runtimeService).createProcessInstanceQuery();
doReturn(null).when(processQuery).singleResult();
StartProcessPayload payload = new StartProcessPayload();
Throwable exception = catchThrowable(() -> processRuntime.startCreatedProcess(processInstanceId, payload));
assertThat(exception).isInstanceOf(NotFoundException.class).hasMessage("Unable to find process instance for the given id:'process-instance-id'");
}
use of org.activiti.api.process.model.payloads.StartProcessPayload 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.payloads.StartProcessPayload in project Activiti by Activiti.
the class ProcessRuntimeImplTest method should_startAnAlreadyCreatedProcessInstance_whenCalled.
@Test
public void should_startAnAlreadyCreatedProcessInstance_whenCalled() {
// given
String processInstanceId = "process-instance-id";
ProcessInstanceQuery processQuery = mock(ProcessInstanceQuery.class);
doReturn(processQuery).when(processQuery).processInstanceId(processInstanceId);
doReturn(processQuery).when(runtimeService).createProcessInstanceQuery();
org.activiti.engine.runtime.ProcessInstance internalProcess = new ExecutionEntityImpl();
internalProcess.setAppVersion(1);
doReturn(internalProcess).when(processQuery).singleResult();
when(runtimeService.startCreatedProcessInstance(internalProcess, new HashMap<>())).thenReturn(internalProcess);
ProcessInstanceImpl apiProcessInstance = new ProcessInstanceImpl();
apiProcessInstance.setBusinessKey("business-result");
apiProcessInstance.setId("999-999");
given(processInstanceConverter.from(internalProcess)).willReturn(apiProcessInstance);
given(securityPoliciesManager.canRead(any())).willReturn(true);
// when
StartProcessPayload payload = new StartProcessPayload();
ProcessInstance createdProcessInstance = processRuntime.startCreatedProcess(processInstanceId, payload);
// then
assertThat(createdProcessInstance.getId()).isEqualTo("999-999");
assertThat(createdProcessInstance.getBusinessKey()).isEqualTo("business-result");
}
Aggregations