use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskHadCandidateUser.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskHadCandidateUser() {
// given
runtimeService.startProcessInstanceByKey("oneTaskProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
// if
identityService.setAuthenticatedUserId("aAssignerId");
taskService.addCandidateUser(taskId, "aUserId");
taskService.addCandidateUser(taskId, "bUserId");
taskService.deleteCandidateUser(taskId, "bUserId");
Task taskAssignee = taskService.newTask("newTask");
taskAssignee.setAssignee("aUserId");
taskService.saveTask(taskAssignee);
// query test
assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskHadCandidateUser("aUserId").count());
assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskHadCandidateUser("bUserId").count());
assertEquals(0, historyService.createHistoricTaskInstanceQuery().taskHadCandidateUser("invalidUserId").count());
// delete test
taskService.deleteTask("newTask", true);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class CommandContextInterceptorTest method testCommandContextNestedFailingCommandsNotExceptions.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testCommandContextNestedFailingCommandsNotExceptions() {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("processThrowingThrowable").startEvent().serviceTask().camundaClass(ThrowErrorJavaDelegate.class).endEvent().done();
deployment(modelInstance);
boolean errorThrown = false;
try {
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
runtimeService.startProcessInstanceByKey("processThrowingThrowable");
return null;
}
});
fail("Exception expected");
} catch (StackOverflowError t) {
// OK
errorThrown = true;
}
assertTrue(ThrowErrorJavaDelegate.executed);
assertTrue(errorThrown);
// Check data base consistency
assertEquals(0, historyService.createHistoricProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstantiationTest method testFailToRestartProcessInstanceSyncWithOtherTenantId.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceSyncWithOtherTenantId() {
// 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()).execute();
fail("expected exception");
} catch (BadUserRequestException e) {
// then
assertThat(e.getMessage(), containsString("Historic process instance cannot be found: historicProcessInstanceId is null"));
}
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstantiationTest method testRestartProcessInstanceSyncWithTenantIdByHistoricProcessInstanceQuery.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testRestartProcessInstanceSyncWithTenantIdByHistoricProcessInstanceQuery() {
// given
ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());
identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE));
// when
runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").historicProcessInstanceQuery(query).execute();
// then
ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
assertNotNull(restartedInstance);
assertEquals(restartedInstance.getTenantId(), TENANT_ONE);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstantiationTest method testRestartProcessInstanceAsyncWithTenantId.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testRestartProcessInstanceAsyncWithTenantId() {
// given
ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE));
// when
Batch batch = runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").processInstanceIds(processInstance.getId()).executeAsync();
batchHelper.completeBatch(batch);
// then
ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
assertNotNull(restartedInstance);
assertEquals(restartedInstance.getTenantId(), TENANT_ONE);
}
Aggregations