use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class UpdateProcessInstancesSuspendStateTest method testBatchSuspensionByHistoricProcessInstanceQuery.
@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 testBatchSuspensionByHistoricProcessInstanceQuery() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when the process instances are suspended
runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).suspend();
// Update the process instances and they are suspended
ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
assertTrue(p1c.isSuspended());
ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
assertTrue(p2c.isSuspended());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class UpdateProcessInstancesSuspendStateTest method testBatchActivatationByHistoricProcessInstanceQuery.
@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 testBatchActivatationByHistoricProcessInstanceQuery() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when the process instances are suspended
runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).suspend();
// when they are activated again
runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).activate();
// Update the process instances and they are active again
ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
assertFalse(p1c.isSuspended());
ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
assertFalse(p2c.isSuspended());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class UpdateSuspendStateUserOperationLogTest method testNoCreationOnSyncBatchJobExecution.
@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_FULL)
public void testNoCreationOnSyncBatchJobExecution() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).suspendAsync();
helper.executeSeedJob(suspendprocess);
// when
rule.getIdentityService().setAuthenticatedUserId("userId");
helper.executeJobs(suspendprocess);
rule.getIdentityService().clearAuthentication();
// then
assertEquals(0, rule.getHistoryService().createUserOperationLogQuery().count());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class UpdateSuspendStateUserOperationLogTest method testLogCreation.
@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_FULL)
public void testLogCreation() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
rule.getIdentityService().setAuthenticatedUserId("userId");
// when
Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).suspendAsync();
helper.executeSeedJob(suspendprocess);
helper.executeJobs(suspendprocess);
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
assertEquals(2, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry asyncEntry = entries.get("async");
assertNotNull(asyncEntry);
assertEquals("ProcessInstance", asyncEntry.getEntityType());
assertEquals("SuspendJob", asyncEntry.getOperationType());
assertNull(asyncEntry.getProcessInstanceId());
assertNull(asyncEntry.getOrgValue());
assertEquals("true", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
assertNotNull(numInstancesEntry);
assertEquals("ProcessInstance", numInstancesEntry.getEntityType());
assertEquals("SuspendJob", numInstancesEntry.getOperationType());
assertNull(numInstancesEntry.getProcessInstanceId());
assertNull(numInstancesEntry.getProcessDefinitionKey());
assertNull(numInstancesEntry.getProcessDefinitionId());
assertNull(numInstancesEntry.getOrgValue());
assertEquals("2", numInstancesEntry.getNewValue());
assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcessInstanceQueryIncidentStatusResolved.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldDeleteIncidentAfterJobWasSuccessfully.bpmn" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcessInstanceQueryIncidentStatusResolved() {
// given a incident processes instance
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("failingProcessWithUserTask", parameters);
executeAvailableJobs();
// when `fail` variable is set to true and job retry count is set to one and executed again
runtimeService.setVariable(pi1.getId(), "fail", false);
Job jobToResolve = managementService.createJobQuery().processInstanceId(pi1.getId()).singleResult();
managementService.setJobRetries(jobToResolve.getId(), 1);
executeAvailableJobs();
// then query for historic process instance with resolved incidents will return one
assertEquals(1, historyService.createHistoricProcessInstanceQuery().incidentStatus("resolved").count());
}
Aggregations