use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesWithListAsync.
@Test
public void shouldSetExternalTaskRetriesWithListAsync() {
List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
ArrayList<String> externalTaskIds = new ArrayList<String>();
for (ExternalTask task : externalTasks) {
externalTaskIds.add(task.getId());
}
// when
Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, null, 5);
// then
executeSeedAndBatchJobs(batch);
externalTasks = externalTaskService.createExternalTaskQuery().list();
for (ExternalTask task : externalTasks) {
Assert.assertEquals(5, (int) task.getRetries());
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldUpdateRetriesByExternalTaskQuery.
@Test
public void shouldUpdateRetriesByExternalTaskQuery() {
// given
ExternalTaskQuery query = externalTaskService.createExternalTaskQuery();
// when
Batch batch = externalTaskService.updateRetries().externalTaskQuery(query).setAsync(5);
executeSeedAndBatchJobs(batch);
// then
List<ExternalTask> tasks = query.list();
assertEquals(6, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(5, (int) task.getRetries());
}
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class ExternalTaskParseTest method testParseExternalTaskWithStringTopic.
@Deployment
public void testParseExternalTaskWithStringTopic() {
Map<String, Object> variables = new HashMap<String, Object>();
runtimeService.startProcessInstanceByKey("oneExternalTaskWithStringTopicProcess", variables);
ExternalTask task = externalTaskService.createExternalTaskQuery().singleResult();
assertEquals("testTopicString", task.getTopicName());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class SetExternalTaskRetriesUserOperationLogTest method testLogCreationForOneExternalTaskId.
@Test
public void testLogCreationForOneExternalTaskId() {
// given
rule.getIdentityService().setAuthenticatedUserId("userId");
// when
ExternalTask externalTask = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
externalTaskService.setRetries(externalTask.getId(), 5);
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(1, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry retriesEntry = entries.get("retries");
Assert.assertNotNull(retriesEntry);
Assert.assertEquals("ProcessInstance", retriesEntry.getEntityType());
Assert.assertEquals("SetExternalTaskRetries", retriesEntry.getOperationType());
Assert.assertEquals(externalTask.getProcessInstanceId(), retriesEntry.getProcessInstanceId());
Assert.assertEquals(externalTask.getProcessDefinitionId(), retriesEntry.getProcessDefinitionId());
Assert.assertEquals(externalTask.getProcessDefinitionKey(), retriesEntry.getProcessDefinitionKey());
Assert.assertNull(retriesEntry.getOrgValue());
Assert.assertEquals("5", retriesEntry.getNewValue());
}
use of org.camunda.bpm.engine.externaltask.ExternalTask in project camunda-bpm-platform by camunda.
the class SetExternalTaskRetriesUserOperationLogTest method testLogCreationSync.
@Test
public void testLogCreationSync() {
// given
rule.getIdentityService().setAuthenticatedUserId("userId");
List<ExternalTask> list = externalTaskService.createExternalTaskQuery().list();
List<String> externalTaskIds = new ArrayList<String>();
for (ExternalTask task : list) {
externalTaskIds.add(task.getId());
}
// when
externalTaskService.setRetries(externalTaskIds, 5);
rule.getIdentityService().clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = rule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(3, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry asyncEntry = entries.get("async");
Assert.assertNotNull(asyncEntry);
Assert.assertEquals("ProcessInstance", asyncEntry.getEntityType());
Assert.assertEquals("SetExternalTaskRetries", asyncEntry.getOperationType());
Assert.assertNull(asyncEntry.getProcessDefinitionId());
Assert.assertNull(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("SetExternalTaskRetries", numInstancesEntry.getOperationType());
Assert.assertNull(numInstancesEntry.getProcessDefinitionId());
Assert.assertNull(numInstancesEntry.getProcessDefinitionKey());
Assert.assertNull(numInstancesEntry.getProcessInstanceId());
Assert.assertNull(numInstancesEntry.getOrgValue());
Assert.assertEquals("6", numInstancesEntry.getNewValue());
UserOperationLogEntry retriesEntry = entries.get("retries");
Assert.assertNotNull(retriesEntry);
Assert.assertEquals("ProcessInstance", retriesEntry.getEntityType());
Assert.assertEquals("SetExternalTaskRetries", retriesEntry.getOperationType());
Assert.assertNull(retriesEntry.getProcessDefinitionId());
Assert.assertNull(retriesEntry.getProcessDefinitionKey());
Assert.assertNull(retriesEntry.getProcessInstanceId());
Assert.assertNull(retriesEntry.getOrgValue());
Assert.assertEquals("5", retriesEntry.getNewValue());
Assert.assertEquals(asyncEntry.getOperationId(), retriesEntry.getOperationId());
}
Aggregations