Search in sources :

Example 11 with ProcessRuntimeConfiguration

use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.

the class ProcessExtensionsIT method processInstanceFailsIfVariableTypeIncorrect.

@Test
public void processInstanceFailsIfVariableTypeIncorrect() {
    ProcessRuntimeConfiguration configuration = processRuntime.configuration();
    assertThat(configuration).isNotNull();
    assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
        processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(INITIAL_VARS_PROCESS).withVariable("age", true).withVariable("name", 7).withVariable("subscribe", "ok").withVariable("birth", "2007-10-01").build());
    }).withMessage("Variables fail type validation: subscribe, name, age");
}
Also used : ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ProcessRuntimeConfiguration

use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.

the class ConformanceBasicProcessRuntimeTest method shouldGetConfiguration.

@Test
public void shouldGetConfiguration() {
    securityUtil.logInAs("user1");
    // when
    ProcessRuntimeConfiguration configuration = processRuntime.configuration();
    // then
    assertThat(configuration).isNotNull();
    // when
    List<ProcessRuntimeEventListener<?>> processRuntimeEventListeners = configuration.processEventListeners();
    List<VariableEventListener<?>> variableEventListeners = configuration.variableEventListeners();
    // then
    assertThat(processRuntimeEventListeners).isNotEmpty();
    assertThat(variableEventListeners).isNotEmpty();
}
Also used : ProcessRuntimeEventListener(org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener) VariableEventListener(org.activiti.api.runtime.shared.events.VariableEventListener) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with ProcessRuntimeConfiguration

use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.

the class ConformanceBasicProcessRuntimeTest method shouldGetConfiguration.

@Test
public void shouldGetConfiguration() {
    securityUtil.logInAs("user1");
    // when
    ProcessRuntimeConfiguration configuration = processRuntime.configuration();
    // then
    assertThat(configuration).isNotNull();
    // when
    List<ProcessRuntimeEventListener<?>> processRuntimeEventListeners = configuration.processEventListeners();
    List<VariableEventListener<?>> variableEventListeners = configuration.variableEventListeners();
    // then
    assertThat(processRuntimeEventListeners).hasSize(11);
    assertThat(variableEventListeners).hasSize(3);
}
Also used : ProcessRuntimeEventListener(org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener) VariableEventListener(org.activiti.api.runtime.shared.events.VariableEventListener) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with ProcessRuntimeConfiguration

use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration 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 15 with ProcessRuntimeConfiguration

use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.

the class ProcessRuntimeIT method shouldGetConfiguration.

@Test
public void shouldGetConfiguration() {
    // when
    ProcessRuntimeConfiguration configuration = processRuntime.configuration();
    // then
    assertThat(configuration).isNotNull();
}
Also used : ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ProcessRuntimeConfiguration (org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration)17 Test (org.junit.jupiter.api.Test)17 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)17 ProcessRuntimeEventListener (org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener)6 VariableEventListener (org.activiti.api.runtime.shared.events.VariableEventListener)6 ProcessInstance (org.activiti.api.process.model.ProcessInstance)4 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 SimpleDateFormat (java.text.SimpleDateFormat)1 UpdateProcessPayload (org.activiti.api.process.model.payloads.UpdateProcessPayload)1