use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyExternalTaskQueryTest method testQueryAuthenticatedTenant.
public void testQueryAuthenticatedTenant() {
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
ExternalTaskQuery query = externalTaskService.createExternalTaskQuery();
assertThat(query.count(), is(1L));
assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L));
assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).count(), is(1L));
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstanceSuspensionStateTest method suspendAndActivateProcessInstancesIncludingExternalTasksForAllTenants.
@Test
public void suspendAndActivateProcessInstancesIncludingExternalTasksForAllTenants() {
// given activated external tasks
ExternalTaskQuery query = engineRule.getExternalTaskService().createExternalTaskQuery();
assertThat(query.active().count(), is(3L));
assertThat(query.suspended().count(), is(0L));
// first suspend
engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).suspend();
assertThat(query.active().count(), is(0L));
assertThat(query.suspended().count(), is(3L));
// then activate
engineRule.getRuntimeService().updateProcessInstanceSuspensionState().byProcessDefinitionKey(PROCESS_DEFINITION_KEY).activate();
assertThat(query.active().count(), is(3L));
assertThat(query.suspended().count(), is(0L));
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery 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.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesAsyncWithExternalTaskQuery.
@Test
public void testSetRetriesAsyncWithExternalTaskQuery() {
when(externalTaskService.createExternalTaskQuery()).thenReturn(new ExternalTaskQueryImpl());
ExternalTaskQueryDto query = new ExternalTaskQueryDto();
query.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("retries", "5");
parameters.put("externalTaskQuery", query);
given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.OK.getStatusCode()).when().post(RETRIES_EXTERNAL_TASKS_ASYNC_URL);
ArgumentCaptor<ExternalTaskQuery> queryCapture = ArgumentCaptor.forClass(ExternalTaskQuery.class);
verify(externalTaskService).updateRetries();
verify(externalTaskService).createExternalTaskQuery();
verifyNoMoreInteractions(externalTaskService);
verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
verify(updateRetriesBuilder).externalTaskQuery(queryCapture.capture());
verify(updateRetriesBuilder).processInstanceQuery(null);
verify(updateRetriesBuilder).historicProcessInstanceQuery(null);
verify(updateRetriesBuilder).setAsync(5);
verifyNoMoreInteractions(updateRetriesBuilder);
ExternalTaskQueryImpl actualQuery = (ExternalTaskQueryImpl) queryCapture.getValue();
assertThat(actualQuery).isNotNull();
assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
use of org.camunda.bpm.engine.externaltask.ExternalTaskQuery in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceQueryTest method setUpMockExternalTaskQuery.
private ExternalTaskQuery setUpMockExternalTaskQuery(List<ExternalTask> mockedTasks) {
ExternalTaskQuery sampleTaskQuery = mock(ExternalTaskQuery.class);
when(sampleTaskQuery.list()).thenReturn(mockedTasks);
when(sampleTaskQuery.count()).thenReturn((long) mockedTasks.size());
when(processEngine.getExternalTaskService().createExternalTaskQuery()).thenReturn(sampleTaskQuery);
return sampleTaskQuery;
}
Aggregations