Search in sources :

Example 1 with UpdateProcessPayload

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);
}
Also used : UpdateProcessPayload(org.activiti.api.process.model.payloads.UpdateProcessPayload) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with UpdateProcessPayload

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);
}
Also used : UpdateProcessPayload(org.activiti.api.process.model.payloads.UpdateProcessPayload) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) ProcessInstance(org.activiti.api.process.model.ProcessInstance) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with UpdateProcessPayload

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);
}
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)

Aggregations

UpdateProcessPayload (org.activiti.api.process.model.payloads.UpdateProcessPayload)3 Test (org.junit.jupiter.api.Test)3 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)2 ProcessInstance (org.activiti.api.process.model.ProcessInstance)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ProcessRuntimeConfiguration (org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration)1 ProcessInstanceImpl (org.activiti.api.runtime.model.impl.ProcessInstanceImpl)1 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)1