Search in sources :

Example 66 with RequiredHistoryLevel

use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.

the class TaskAuthorizationTest method testStandaloneTaskUpdateVariablesLocalWithReadPermissionOnTask.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskUpdateVariablesLocalWithReadPermissionOnTask() {
    // given
    String taskId = "myTask";
    createTask(taskId);
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
    // when (1)
    ((TaskServiceImpl) taskService).updateVariablesLocal(taskId, getVariables(), null);
    // then (1)
    disableAuthorization();
    verifyQueryResults(query, 1);
    enableAuthorization();
    // when (2)
    ((TaskServiceImpl) taskService).updateVariablesLocal(taskId, null, Arrays.asList(VARIABLE_NAME));
    // then (2)
    disableAuthorization();
    verifyQueryResults(query, 0);
    enableAuthorization();
    // when (3)
    ((TaskServiceImpl) taskService).updateVariablesLocal(taskId, getVariables(), Arrays.asList(VARIABLE_NAME));
    // then (3)
    disableAuthorization();
    verifyQueryResults(query, 0);
    enableAuthorization();
    deleteTask(taskId, true);
    List<HistoricVariableInstance> deletedVariables = historyService.createHistoricVariableInstanceQuery().includeDeleted().list();
    Assert.assertEquals("DELETED", deletedVariables.get(0).getState());
    Assert.assertEquals("DELETED", deletedVariables.get(1).getState());
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) TaskServiceImpl(org.camunda.bpm.engine.impl.TaskServiceImpl) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 67 with RequiredHistoryLevel

use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testDeleteProcessInstanceWithoutSubprocessInstances.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testDeleteProcessInstanceWithoutSubprocessInstances() {
    // given a process instance with subprocesses
    BpmnModelInstance calling = prepareComplexProcess("A", "B", "C");
    BpmnModelInstance calledA = prepareSimpleProcess("A");
    BpmnModelInstance calledB = prepareSimpleProcess("B");
    BpmnModelInstance calledC = prepareSimpleProcess("C");
    testRule.deploy(calling, calledA, calledB, calledC);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("calling");
    List<ProcessInstance> subInstances = runtimeService.createProcessInstanceQuery().superProcessInstanceId(processInstance.getId()).list();
    // when the process instance is deleted and we do skip sub processes
    String id = processInstance.getId();
    runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, true);
    // then
    testRule.assertProcessEnded(id);
    for (ProcessInstance subInstance : subInstances) {
        testRule.assertProcessNotEnded(subInstance.getId());
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 68 with RequiredHistoryLevel

use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testDeleteProcessInstanceSkipIoMappings.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcessWithIoMappings.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testDeleteProcessInstanceSkipIoMappings() {
    // given a process instance
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("ioMappingProcess");
    // when the process instance is deleted and we do skip the io mappings
    runtimeService.deleteProcessInstance(instance.getId(), null, false, true, true);
    // then
    testRule.assertProcessEnded(instance.getId());
    assertEquals(1, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.getId()).list().size());
    assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 69 with RequiredHistoryLevel

use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.

the class RuntimeServiceTest method testCascadingDeleteSubprocessInstanceWithoutSkipIoMappings.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Calling.bpmn20.xml", "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Called.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testCascadingDeleteSubprocessInstanceWithoutSkipIoMappings() {
    // given a process instance
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess");
    ProcessInstance instance2 = runtimeService.createProcessInstanceQuery().superProcessInstanceId(instance.getId()).singleResult();
    // when the process instance is deleted and we do not skip the io mappings
    runtimeService.deleteProcessInstance(instance.getId(), "test_purposes", false, true, false);
    // then
    testRule.assertProcessEnded(instance.getId());
    assertEquals(2, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance2.getId()).list().size());
    assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count());
    assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("outputMappingExecuted").count());
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 70 with RequiredHistoryLevel

use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.

the class UpdateProcessInstancesSuspendStateAsyncTest method testBatchActivationByHistoricProcessInstanceQuery.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testBatchActivationByHistoricProcessInstanceQuery() {
    // given
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
    // when
    Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).suspendAsync();
    helper.executeSeedJob(suspendprocess);
    helper.executeJobs(suspendprocess);
    Batch activateprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).activateAsync();
    helper.executeSeedJob(activateprocess);
    helper.executeJobs(activateprocess);
    // then
    ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
    assertFalse(p1c.isSuspended());
    ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
    assertFalse(p2c.isSuspended());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)76 Test (org.junit.Test)47 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)43 Deployment (org.camunda.bpm.engine.test.Deployment)24 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)17 Batch (org.camunda.bpm.engine.batch.Batch)13 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)13 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)12 Task (org.camunda.bpm.engine.task.Task)12 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)12 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)11 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)10 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 Calendar (java.util.Calendar)6 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)6 Job (org.camunda.bpm.engine.runtime.Job)6 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)6 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 GregorianCalendar (java.util.GregorianCalendar)4