use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceUserOperationLogTest method testNoCreationOnSyncBatchJobExecution.
@Test
public void testNoCreationOnSyncBatchJobExecution() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("user1").processInstanceIds(processInstance.getId()).executeAsync();
helper.executeSeedJob(batch);
// when
rule.getIdentityService().setAuthenticatedUserId("userId");
helper.executeJobs(batch);
rule.getIdentityService().clearAuthentication();
// then
Assert.assertEquals(0, rule.getHistoryService().createUserOperationLogQuery().count());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceUserOperationLogTest method testLogCreationSync.
@Test
public void testLogCreationSync() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
rule.getIdentityService().setAuthenticatedUserId("userId");
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("process1");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("process1");
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startAfterActivity("user1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).execute();
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().operationType("RestartProcessInstance").list();
Assert.assertEquals(2, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry asyncEntry = entries.get("async");
Assert.assertNotNull(asyncEntry);
Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
Assert.assertEquals("RestartProcessInstance", asyncEntry.getOperationType());
Assert.assertEquals(processDefinition.getId(), asyncEntry.getProcessDefinitionId());
Assert.assertEquals(processDefinition.getKey(), asyncEntry.getProcessDefinitionKey());
Assert.assertNull(asyncEntry.getProcessInstanceId());
Assert.assertNull(asyncEntry.getOrgValue());
Assert.assertEquals("false", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
Assert.assertNotNull(numInstancesEntry);
Assert.assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
Assert.assertEquals("RestartProcessInstance", numInstancesEntry.getOperationType());
Assert.assertEquals(processDefinition.getId(), numInstancesEntry.getProcessDefinitionId());
Assert.assertEquals(processDefinition.getKey(), numInstancesEntry.getProcessDefinitionKey());
Assert.assertNull(numInstancesEntry.getProcessInstanceId());
Assert.assertNull(numInstancesEntry.getOrgValue());
Assert.assertEquals("2", numInstancesEntry.getNewValue());
Assert.assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldRestartProcessInstanceWithBusinessKey.
@Test
public void shouldRestartProcessInstanceWithBusinessKey() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", "businessKey", (String) null);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult();
assertNotNull(restartedProcessInstance.getBusinessKey());
assertEquals("businessKey", restartedProcessInstance.getBusinessKey());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method shouldRestartProcessInstanceWithoutCaseInstanceId.
@Test
public void shouldRestartProcessInstanceWithoutCaseInstanceId() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", null, "caseInstanceId");
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
// when
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult();
assertNull(restartedProcessInstance.getCaseInstanceId());
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceSyncTest method restartNotExistingProcessInstance.
@Test
public void restartNotExistingProcessInstance() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
try {
runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("bar").processInstanceIds("aaa").execute();
fail("exception expected");
} catch (BadUserRequestException e) {
Assert.assertThat(e.getMessage(), containsString("Historic process instance cannot be found"));
}
}
Aggregations