Search in sources :

Example 6 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition 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 7 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project Activiti by Activiti.

the class ProcessRuntimeIT method should_OnlyProcessDefinitionsFromLatestVersionRetrieved.

@Test
public void should_OnlyProcessDefinitionsFromLatestVersionRetrieved() {
    Deployment deployment = processRuntime.selectLatestDeployment();
    Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(PAGEABLE);
    assertThat(processDefinitionPage.getContent().stream().filter(c -> c.getKey().equals(SUPER_PROCESS))).extracting(ProcessDefinition::getAppVersion).containsOnly(deployment.getVersion().toString());
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) ProcessRuntimeImpl(org.activiti.runtime.api.impl.ProcessRuntimeImpl) Task(org.activiti.api.task.model.Task) APIVariableInstanceConverter(org.activiti.runtime.api.model.impl.APIVariableInstanceConverter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Mockito.spy(org.mockito.Mockito.spy) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) Deployment(org.activiti.api.process.model.Deployment) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) RepositoryService(org.activiti.engine.RepositoryService) BigDecimal(java.math.BigDecimal) ProcessSecurityPoliciesManager(org.activiti.core.common.spring.security.policies.ProcessSecurityPoliciesManager) ProcessAdminRuntimeImpl(org.activiti.runtime.api.impl.ProcessAdminRuntimeImpl) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) APIProcessInstanceConverter(org.activiti.runtime.api.model.impl.APIProcessInstanceConverter) TaskRuntime(org.activiti.api.task.runtime.TaskRuntime) APIProcessDefinitionConverter(org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter) ProcessVariablesPayloadValidator(org.activiti.runtime.api.impl.ProcessVariablesPayloadValidator) ProcessInstance(org.activiti.api.process.model.ProcessInstance) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) APIDeploymentConverter(org.activiti.runtime.api.model.impl.APIDeploymentConverter) TaskPayloadBuilder(org.activiti.api.task.model.builders.TaskPayloadBuilder) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UpdateProcessPayload(org.activiti.api.process.model.payloads.UpdateProcessPayload) Page(org.activiti.api.runtime.shared.query.Page) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) StartProcessPayload(org.activiti.api.process.model.payloads.StartProcessPayload) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) RuntimeTestConfiguration(org.activiti.spring.boot.RuntimeTestConfiguration) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) ProcessAdminRuntime(org.activiti.api.process.runtime.ProcessAdminRuntime) VariableInstance(org.activiti.api.model.shared.model.VariableInstance) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) Deployment(org.activiti.api.process.model.Deployment) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project Activiti by Activiti.

the class ProcessRuntimeIT method shouldGetProcessDefinitionFromDefinitionKey.

@Test
public void shouldGetProcessDefinitionFromDefinitionKey() {
    // when
    ProcessDefinition categorizeHumanProcess = processRuntime.processDefinition(CATEGORIZE_HUMAN_PROCESS);
    // then
    assertThat(categorizeHumanProcess).isNotNull();
    assertThat(categorizeHumanProcess.getName()).isEqualTo(CATEGORIZE_HUMAN_PROCESS);
    assertThat(categorizeHumanProcess.getId()).contains(CATEGORIZE_HUMAN_PROCESS);
}
Also used : ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project Activiti by Activiti.

the class ProcessRuntimeSecurityPoliciesIT method getRestrictedProcessDefs.

@Test
public void getRestrictedProcessDefs() {
    securityUtil.logInAs("user");
    // @TODO: I should get the security policies defined here.
    ProcessRuntimeConfiguration configuration = processRuntime.configuration();
    assertThat(configuration).isNotNull();
    Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(Pageable.of(0, 50));
    assertThat(processDefinitionPage.getContent()).isNotNull();
    assertThat(processDefinitionPage.getContent()).hasSize(2);
}
Also used : ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) ProcessRuntimeConfiguration(org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project Activiti by Activiti.

the class ProcessDefinitionFormKeyIT method processDefinitionHasFormKey.

@Test
public void processDefinitionHasFormKey() {
    securityUtil.logInAs("garth");
    ProcessDefinition processDefinition = processRuntime.processDefinition(SINGLE_TASK_PROCESS);
    assertThat(processDefinition.getFormKey()).isEqualTo("startForm");
}
Also used : ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)46 Test (org.junit.jupiter.api.Test)25 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)19 CloudProcessDefinition (org.activiti.cloud.api.process.model.CloudProcessDefinition)15 BeforeEach (org.junit.jupiter.api.BeforeEach)9 PagedResources (org.springframework.hateoas.PagedResources)8 ProcessInstance (org.activiti.api.process.model.ProcessInstance)5 UpdateProcessPayload (org.activiti.api.process.model.payloads.UpdateProcessPayload)4 ProcessRuntimeConfiguration (org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration)4 PageImpl (org.activiti.runtime.api.query.impl.PageImpl)4 InputStream (java.io.InputStream)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)3 SignalPayload (org.activiti.api.process.model.payloads.SignalPayload)3 ProcessRuntime (org.activiti.api.process.runtime.ProcessRuntime)3 Page (org.activiti.api.runtime.shared.query.Page)3 Pageable (org.activiti.api.runtime.shared.query.Pageable)3 RepositoryService (org.activiti.engine.RepositoryService)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2