use of org.camunda.bpm.engine.ExternalTaskService in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceImpl method updateRetries.
protected UpdateExternalTaskRetriesBuilder updateRetries(SetRetriesForExternalTasksDto retriesDto) {
ExternalTaskService externalTaskService = getProcessEngine().getExternalTaskService();
List<String> externalTaskIds = retriesDto.getExternalTaskIds();
List<String> processInstanceIds = retriesDto.getProcessInstanceIds();
ExternalTaskQuery externalTaskQuery = null;
ProcessInstanceQuery processInstanceQuery = null;
HistoricProcessInstanceQuery historicProcessInstanceQuery = null;
ExternalTaskQueryDto externalTaskQueryDto = retriesDto.getExternalTaskQuery();
if (externalTaskQueryDto != null) {
externalTaskQuery = externalTaskQueryDto.toQuery(getProcessEngine());
}
ProcessInstanceQueryDto processInstanceQueryDto = retriesDto.getProcessInstanceQuery();
if (processInstanceQueryDto != null) {
processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine());
}
HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = retriesDto.getHistoricProcessInstanceQuery();
if (historicProcessInstanceQueryDto != null) {
historicProcessInstanceQuery = historicProcessInstanceQueryDto.toQuery(getProcessEngine());
}
return externalTaskService.updateRetries().externalTaskIds(externalTaskIds).processInstanceIds(processInstanceIds).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery);
}
use of org.camunda.bpm.engine.ExternalTaskService in project camunda-bpm-platform by camunda.
the class ExternalTaskResourceImpl method complete.
@Override
public void complete(CompleteExternalTaskDto dto) {
ExternalTaskService externalTaskService = engine.getExternalTaskService();
VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper);
VariableMap localVariables = VariableValueDto.toMap(dto.getLocalVariables(), engine, objectMapper);
try {
externalTaskService.complete(externalTaskId, dto.getWorkerId(), variables, localVariables);
} catch (NotFoundException e) {
throw new RestException(Status.NOT_FOUND, e, "External task with id " + externalTaskId + " does not exist");
} catch (BadUserRequestException e) {
throw new RestException(Status.BAD_REQUEST, e, e.getMessage());
}
}
use of org.camunda.bpm.engine.ExternalTaskService 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.ExternalTaskService in project camunda-bpm-platform by camunda.
the class MockedProcessEngineProvider method mockServices.
private void mockServices(ProcessEngine engine) {
RepositoryService repoService = mock(RepositoryService.class);
IdentityService identityService = mock(IdentityService.class);
TaskService taskService = mock(TaskService.class);
RuntimeService runtimeService = mock(RuntimeService.class);
FormService formService = mock(FormService.class);
HistoryService historyService = mock(HistoryService.class);
ManagementService managementService = mock(ManagementService.class);
CaseService caseService = mock(CaseService.class);
FilterService filterService = mock(FilterService.class);
ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
when(engine.getRepositoryService()).thenReturn(repoService);
when(engine.getIdentityService()).thenReturn(identityService);
when(engine.getTaskService()).thenReturn(taskService);
when(engine.getRuntimeService()).thenReturn(runtimeService);
when(engine.getFormService()).thenReturn(formService);
when(engine.getHistoryService()).thenReturn(historyService);
when(engine.getManagementService()).thenReturn(managementService);
when(engine.getCaseService()).thenReturn(caseService);
when(engine.getFilterService()).thenReturn(filterService);
when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
Aggregations