use of org.activiti.api.process.model.payloads.UpdateProcessPayload in project Activiti by Activiti.
the class ProcessRuntimeIT method updateProcessInstanceAdmin.
@Test
public void updateProcessInstanceAdmin() {
securityUtil.logInAs("admin");
Page<ProcessDefinition> processDefinitionPage = processAdminRuntime.processDefinitions(Pageable.of(0, 50));
assertThat(processDefinitionPage.getContent()).isNotNull();
assertThat(processDefinitionPage.getContent()).extracting(ProcessDefinition::getKey).contains(CATEGORIZE_HUMAN_PROCESS);
// start a process with a business key to check filters
ProcessInstance categorizeProcess = processAdminRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(CATEGORIZE_HUMAN_PROCESS).withVariable("expectedKey", true).withBusinessKey("my business key").withName("my process name").build());
assertThat(categorizeProcess).isNotNull();
assertThat(categorizeProcess.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
assertThat(categorizeProcess.getName()).isEqualTo("my process name");
// update a process
Page<ProcessInstance> processInstancePage = processAdminRuntime.processInstances(PAGEABLE);
ProcessInstance processInstance = processInstancePage.getContent().get(0);
UpdateProcessPayload updateProcessPayload = ProcessPayloadBuilder.update().withProcessInstanceId(processInstance.getId()).withBusinessKey(processInstance.getBusinessKey() + " UPDATED").withName(processInstance.getName() + " UPDATED").build();
ProcessInstance updatedProcessInstance = processAdminRuntime.update(updateProcessPayload);
assertThat(updatedProcessInstance).isNotNull();
processInstancePage = processAdminRuntime.processInstances(PAGEABLE);
assertThat(processInstancePage).isNotNull();
assertThat(processInstancePage.getContent()).hasSize(1);
processInstance = processInstancePage.getContent().get(0);
assertThat(processInstance.getName()).isEqualTo("my process name UPDATED");
assertThat(processInstance.getBusinessKey()).isEqualTo("my business key UPDATED");
// delete a process to avoid possible problems with other tests
ProcessInstance deletedProcessInstance = processAdminRuntime.delete(ProcessPayloadBuilder.delete(categorizeProcess));
assertThat(deletedProcessInstance).isNotNull();
assertThat(deletedProcessInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.CANCELLED);
}
use of org.activiti.api.process.model.payloads.UpdateProcessPayload in project Activiti by Activiti.
the class ProcessRuntimeIT method updateProcessInstance.
@Test
public void updateProcessInstance() {
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(PAGEABLE);
assertThat(processDefinitionPage.getContent()).isNotNull();
assertThat(processDefinitionPage.getContent()).extracting(ProcessDefinition::getKey).contains(CATEGORIZE_HUMAN_PROCESS);
// start a process with a business key to check filters
ProcessInstance categorizeProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(CATEGORIZE_HUMAN_PROCESS).withVariable("expectedKey", true).withBusinessKey("my business key").withName("my process name").build());
assertThat(categorizeProcess).isNotNull();
assertThat(categorizeProcess.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
assertThat(categorizeProcess.getName()).isEqualTo("my process name");
// assertThat(categorizeProcess.getDescription()).isNull();
//
// To do: currently Description is not possible to update
//
// update a process
Page<ProcessInstance> processInstancePage = processRuntime.processInstances(PAGEABLE);
ProcessInstance processInstance = processInstancePage.getContent().get(0);
UpdateProcessPayload updateProcessPayload = ProcessPayloadBuilder.update().withProcessInstanceId(processInstance.getId()).withBusinessKey(processInstance.getBusinessKey() + " UPDATED").withName(processInstance.getName() + " UPDATED").build();
ProcessInstance updatedProcessInstance = processRuntime.update(updateProcessPayload);
assertThat(updatedProcessInstance).isNotNull();
processInstancePage = processRuntime.processInstances(PAGEABLE);
assertThat(processInstancePage).isNotNull();
assertThat(processInstancePage.getContent()).hasSize(1);
processInstance = processInstancePage.getContent().get(0);
assertThat(processInstance.getName()).isEqualTo("my process name UPDATED");
assertThat(processInstance.getBusinessKey()).isEqualTo("my business key UPDATED");
// delete a process to avoid possible problems with other tests
ProcessInstance deletedProcessInstance = processRuntime.delete(ProcessPayloadBuilder.delete(categorizeProcess));
assertThat(deletedProcessInstance).isNotNull();
assertThat(deletedProcessInstance.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.CANCELLED);
}
use of org.activiti.api.process.model.payloads.UpdateProcessPayload 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);
}
Aggregations