Search in sources :

Example 6 with ProcessInstanceImpl

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());
}
Also used : ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl)

Example 7 with ProcessInstanceImpl

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());
}
Also used : ProcessInstanceBuilder(org.activiti.engine.runtime.ProcessInstanceBuilder) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) ProcessInstance(org.activiti.api.process.model.ProcessInstance) CreateProcessInstancePayload(org.activiti.api.process.model.payloads.CreateProcessInstancePayload) Test(org.junit.jupiter.api.Test)

Example 8 with ProcessInstanceImpl

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);
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) UpdateProcessPayload(org.activiti.api.process.model.payloads.UpdateProcessPayload) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) Test(org.junit.jupiter.api.Test)

Example 9 with ProcessInstanceImpl

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");
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) ExecutionEntityImpl(org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl) StartProcessPayload(org.activiti.api.process.model.payloads.StartProcessPayload) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessInstanceImpl (org.activiti.api.runtime.model.impl.ProcessInstanceImpl)9 Test (org.junit.jupiter.api.Test)3 ProcessInstance (org.activiti.api.process.model.ProcessInstance)2 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)2 CreateProcessInstancePayload (org.activiti.api.process.model.payloads.CreateProcessInstancePayload)1 StartProcessPayload (org.activiti.api.process.model.payloads.StartProcessPayload)1 UpdateProcessPayload (org.activiti.api.process.model.payloads.UpdateProcessPayload)1 ProcessDefinitionImpl (org.activiti.api.runtime.model.impl.ProcessDefinitionImpl)1 ExecutionEntityImpl (org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl)1 ProcessInstanceBuilder (org.activiti.engine.runtime.ProcessInstanceBuilder)1