use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method setUpRuntimeData.
@Before
public void setUpRuntimeData() {
externalTaskService = mock(ExternalTaskService.class);
when(processEngine.getExternalTaskService()).thenReturn(externalTaskService);
runtimeServiceMock = mock(RuntimeServiceImpl.class);
when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock);
historyServiceMock = mock(HistoryServiceImpl.class);
when(processEngine.getHistoryService()).thenReturn(historyServiceMock);
// locked external task
lockedExternalTaskMock = MockProvider.createMockLockedExternalTask();
// fetching
fetchTopicBuilder = mock(ExternalTaskQueryTopicBuilder.class);
when(externalTaskService.fetchAndLock(anyInt(), any(String.class))).thenReturn(fetchTopicBuilder);
when(externalTaskService.fetchAndLock(anyInt(), any(String.class), any(Boolean.class))).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.topic(any(String.class), anyLong())).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.variables(anyListOf(String.class))).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.variables(any(String[].class))).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.enableCustomObjectDeserialization()).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.topic(any(String.class), anyLong())).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.businessKey(any(String.class))).thenReturn(fetchTopicBuilder);
when(fetchTopicBuilder.processInstanceVariableEquals(anyMapOf(String.class, Object.class))).thenReturn(fetchTopicBuilder);
Batch batch = createMockBatch();
updateRetriesBuilder = mock(UpdateExternalTaskRetriesBuilder.class);
when(externalTaskService.updateRetries()).thenReturn(updateRetriesBuilder);
when(updateRetriesBuilder.externalTaskIds(anyListOf(String.class))).thenReturn(updateRetriesBuilder);
when(updateRetriesBuilder.processInstanceIds(anyListOf(String.class))).thenReturn(updateRetriesBuilder);
when(updateRetriesBuilder.externalTaskQuery(any(ExternalTaskQuery.class))).thenReturn(updateRetriesBuilder);
when(updateRetriesBuilder.processInstanceQuery(any(ProcessInstanceQuery.class))).thenReturn(updateRetriesBuilder);
when(updateRetriesBuilder.historicProcessInstanceQuery(any(HistoricProcessInstanceQuery.class))).thenReturn(updateRetriesBuilder);
when(updateRetriesBuilder.setAsync(anyInt())).thenReturn(batch);
// querying
externalTaskQueryMock = mock(ExternalTaskQuery.class);
when(externalTaskQueryMock.externalTaskId(any(String.class))).thenReturn(externalTaskQueryMock);
when(externalTaskService.createExternalTaskQuery()).thenReturn(externalTaskQueryMock);
// external task
externalTaskMock = MockProvider.createMockExternalTask();
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldUpdateRetriesByHistoricProcessInstanceQuery.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void shouldUpdateRetriesByHistoricProcessInstanceQuery() {
// given
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
// when
Batch batch = externalTaskService.updateRetries().historicProcessInstanceQuery(query).setAsync(5);
executeSeedAndBatchJobs(batch);
// then
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().list();
assertEquals(6, tasks.size());
for (ExternalTask task : tasks) {
assertEquals(5, (int) task.getRetries());
}
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesWithListAndQueryAsync.
@Test
public void shouldSetExternalTaskRetriesWithListAndQueryAsync() {
ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery();
List<ExternalTask> externalTasks = externalTaskQuery.list();
ArrayList<String> externalTaskIds = new ArrayList<String>();
for (ExternalTask task : externalTasks) {
externalTaskIds.add(task.getId());
}
// when
Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, externalTaskQuery, 5);
// then
executeSeedAndBatchJobs(batch);
externalTasks = externalTaskService.createExternalTaskQuery().list();
for (ExternalTask task : externalTasks) {
Assert.assertEquals(5, (int) task.getRetries());
}
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldSetExternalTaskRetriesWithDifferentListAndQueryAsync.
@Test
public void shouldSetExternalTaskRetriesWithDifferentListAndQueryAsync() {
// given
ExternalTaskQuery externalTaskQuery = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0));
List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(processInstanceIds.size() - 1)).list();
ArrayList<String> externalTaskIds = new ArrayList<String>();
for (ExternalTask task : externalTasks) {
externalTaskIds.add(task.getId());
}
// when
Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, externalTaskQuery, 8);
executeSeedAndBatchJobs(batch);
// then
ExternalTask task = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(0)).singleResult();
Assert.assertEquals(8, (int) task.getRetries());
List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().processInstanceId(processInstanceIds.get(processInstanceIds.size() - 1)).list();
for (ExternalTask t : tasks) {
Assert.assertEquals(8, (int) t.getRetries());
}
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method cleanBatch.
@After
public void cleanBatch() {
List<Batch> batches = managementService.createBatchQuery().list();
if (batches.size() > 0) {
for (Batch batch : batches) {
managementService.deleteBatch(batch.getId(), true);
}
}
HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
if (historicBatch != null) {
historyService.deleteHistoricBatch(historicBatch.getId());
}
}
Aggregations