Search in sources :

Example 6 with RequiredHistoryLevel

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

the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceAsyncWithOtherTenantId.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceAsyncWithOtherTenantId() {
    // given
    ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
    identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
    try {
        // when
        runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").processInstanceIds(processInstance.getId()).executeAsync();
    } catch (ProcessEngineException e) {
        assertThat(e.getMessage(), containsString("Cannot restart process instances of process definition '" + processInstance.getProcessDefinitionId() + "' because it belongs to no authenticated tenant."));
    }
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 7 with RequiredHistoryLevel

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

the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceAsyncWithOtherTenantIdByHistoricProcessInstanceQuery.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceAsyncWithOtherTenantIdByHistoricProcessInstanceQuery() {
    // given
    ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());
    identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
    try {
        // when
        runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").historicProcessInstanceQuery(query).executeAsync();
    } catch (ProcessEngineException e) {
        assertThat(e.getMessage(), containsString("processInstanceIds is empty"));
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 8 with RequiredHistoryLevel

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

the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery() {
    // given
    ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());
    identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));
    try {
        // when
        runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").historicProcessInstanceQuery(query).execute();
        fail("expected exception");
    } catch (BadUserRequestException e) {
        // then
        assertThat(e.getMessage(), containsString("processInstanceIds is empty"));
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 9 with RequiredHistoryLevel

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

the class RuntimeServiceTest method testDeleteProcessInstanceWithoutSkipIoMappings.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcessWithIoMappings.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testDeleteProcessInstanceWithoutSkipIoMappings() {
    // given a process instance
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("ioMappingProcess");
    // when the process instance is deleted and we do not skip the io mappings
    runtimeService.deleteProcessInstance(instance.getId(), null, false, true, false);
    // then
    testRule.assertProcessEnded(instance.getId());
    assertEquals(2, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.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 10 with RequiredHistoryLevel

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

the class RuntimeServiceTest method testDeleteProcessInstanceWithSubprocessInstances.

@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testDeleteProcessInstanceWithSubprocessInstances() {
    // given a process instance with subprocesses
    BpmnModelInstance calling = prepareComplexProcess("A", "B", "A");
    BpmnModelInstance calledA = prepareSimpleProcess("A");
    BpmnModelInstance calledB = prepareSimpleProcess("B");
    testRule.deploy(calling, calledA, calledB);
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("calling");
    List<ProcessInstance> subInstances = runtimeService.createProcessInstanceQuery().superProcessInstanceId(instance.getId()).list();
    // when the process instance is deleted and we do not skip sub processes
    String id = instance.getId();
    runtimeService.deleteProcessInstance(id, "test_purposes", false, true, false, false);
    // then
    testRule.assertProcessEnded(id);
    for (ProcessInstance subInstance : subInstances) {
        testRule.assertProcessEnded(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)

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