use of org.activiti.api.runtime.model.impl.ProcessInstanceImpl in project Activiti by Activiti.
the class ProcessRuntimeImpl method removeVariables.
@Override
public void removeVariables(RemoveProcessVariablesPayload removeProcessVariablesPayload) {
ProcessInstanceImpl processInstance = (ProcessInstanceImpl) processInstance(removeProcessVariablesPayload.getProcessInstanceId());
checkUserCanWrite(processInstance.getProcessDefinitionKey());
runtimeService.removeVariables(removeProcessVariablesPayload.getProcessInstanceId(), removeProcessVariablesPayload.getVariableNames());
}
use of org.activiti.api.runtime.model.impl.ProcessInstanceImpl in project Activiti by Activiti.
the class ProcessRuntimeImplTest method should_createAProcessInstance_whenCreateIsCalled.
@Test
public void should_createAProcessInstance_whenCreateIsCalled() {
// given
String processDefinitionId = "processDefinitionId";
ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
processDefinition.setId(processDefinitionId);
processDefinition.setKey("key");
CreateProcessInstancePayload createPayload = ProcessPayloadBuilder.create().withProcessDefinitionId(processDefinitionId).withProcessDefinitionKey("key").withName("test-create").build();
doReturn(processDefinition).when(processRuntime).getProcessDefinitionAndCheckUserHasRights(createPayload.getProcessDefinitionId(), createPayload.getProcessDefinitionKey());
ProcessInstanceBuilder processInstanceBuilder = mock(ProcessInstanceBuilder.class, Answers.RETURNS_SELF);
given(runtimeService.createProcessInstanceBuilder()).willReturn(processInstanceBuilder);
org.activiti.engine.runtime.ProcessInstance internalProcessInstance = mock(org.activiti.engine.runtime.ProcessInstance.class);
given(processInstanceBuilder.create()).willReturn(internalProcessInstance);
ProcessInstanceImpl apiProcessInstance = new ProcessInstanceImpl();
given(processInstanceConverter.from(internalProcessInstance)).willReturn(apiProcessInstance);
// when
ProcessInstance createdProcessInstance = processRuntime.create(createPayload);
// then
assertThat(createdProcessInstance).isEqualTo(apiProcessInstance);
verify(processInstanceBuilder).processDefinitionId(processDefinition.getId());
verify(processInstanceBuilder).processDefinitionKey(processDefinition.getKey());
verify(processInstanceBuilder).name(createPayload.getName());
}
use of org.activiti.api.runtime.model.impl.ProcessInstanceImpl in project Activiti by Activiti.
the class ProcessRuntimeImplTest method updateShouldBeAbleToUpdateNameBusinessKey.
@Test
public void updateShouldBeAbleToUpdateNameBusinessKey() {
// given
ProcessInstanceImpl process = new ProcessInstanceImpl();
process.setId("processId");
process.setProcessDefinitionKey("processDefinitionKey");
doReturn(process).when(processRuntime).processInstance("processId");
doReturn(true).when(securityPoliciesManager).canWrite("processDefinitionKey");
ProcessInstanceQuery processQuery = mock(ProcessInstanceQuery.class);
doReturn(processQuery).when(processQuery).processInstanceId("processId");
doReturn(processQuery).when(runtimeService).createProcessInstanceQuery();
org.activiti.engine.runtime.ProcessInstance internalProcess = mock(org.activiti.engine.runtime.ProcessInstance.class);
doReturn(internalProcess).when(processQuery).singleResult();
UpdateProcessPayload updateProcessPayload = ProcessPayloadBuilder.update().withProcessInstanceId("processId").withBusinessKey("businessKey").withName("name").build();
// when
processRuntime.update(updateProcessPayload);
// then
verify(runtimeService).updateBusinessKey("processId", "businessKey");
verifyNoMoreInteractions(internalProcess);
}
use of org.activiti.api.runtime.model.impl.ProcessInstanceImpl 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