use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldThrowProcessEngineExceptionDuringTimeout.
@Test
public void shouldThrowProcessEngineExceptionDuringTimeout() {
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(500L);
when(fetchTopicBuilder.execute()).thenReturn(Collections.<LockedExternalTask>emptyList()).thenReturn(Collections.<LockedExternalTask>emptyList()).thenThrow(new ProcessEngineException("anExceptionMessage"));
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").then().expect().body("type", equalTo(ProcessEngineException.class.getSimpleName())).body("message", equalTo("anExceptionMessage")).statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE);
verify(fetchTopicBuilder, atLeastOnce()).execute();
}
use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldResponseImmediatelyDueToAvailableTasks.
@Test
public void shouldResponseImmediatelyDueToAvailableTasks() {
when(fetchTopicBuilder.execute()).thenReturn(new ArrayList<LockedExternalTask>(Collections.singleton(lockedExternalTaskMock)));
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(500L);
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).then().expect().body("size()", is(1)).statusCode(Status.OK.getStatusCode()).when().post(FETCH_EXTERNAL_TASK_URL);
}
use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldSetAuthenticationProperly.
@Ignore
@Test
public void shouldSetAuthenticationProperly() {
when(identityServiceMock.getCurrentAuthentication()).thenReturn(new Authentication(MockProvider.EXAMPLE_USER_ID, groupIds, tenantIds));
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(500L);
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE);
ArgumentCaptor<Authentication> argumentCaptor = ArgumentCaptor.forClass(Authentication.class);
verify(identityServiceMock, atLeastOnce()).setAuthentication(argumentCaptor.capture());
assertThat(argumentCaptor.getValue().getUserId(), is(MockProvider.EXAMPLE_USER_ID));
assertThat(argumentCaptor.getValue().getGroupIds(), is(groupIds));
assertThat(argumentCaptor.getValue().getTenantIds(), is(tenantIds));
}
use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldFetchAndLock.
@Test
public void shouldFetchAndLock() {
when(fetchTopicBuilder.execute()).thenReturn(new ArrayList<LockedExternalTask>(Collections.singleton(lockedExternalTaskMock)));
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(null, true, true, false);
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").then().expect().statusCode(Status.OK.getStatusCode()).body("[0].id", equalTo(MockProvider.EXTERNAL_TASK_ID)).body("[0].topicName", equalTo(MockProvider.EXTERNAL_TASK_TOPIC_NAME)).body("[0].workerId", equalTo(MockProvider.EXTERNAL_TASK_WORKER_ID)).body("[0].lockExpirationTime", equalTo(MockProvider.EXTERNAL_TASK_LOCK_EXPIRATION_TIME)).body("[0].processInstanceId", equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)).body("[0].executionId", equalTo(MockProvider.EXAMPLE_EXECUTION_ID)).body("[0].activityId", equalTo(MockProvider.EXAMPLE_ACTIVITY_ID)).body("[0].activityInstanceId", equalTo(MockProvider.EXAMPLE_ACTIVITY_INSTANCE_ID)).body("[0].processDefinitionId", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).body("[0].processDefinitionKey", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)).body("[0].tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).body("[0].retries", equalTo(MockProvider.EXTERNAL_TASK_RETRIES)).body("[0].errorMessage", equalTo(MockProvider.EXTERNAL_TASK_ERROR_MESSAGE)).body("[0].errorMessage", equalTo(MockProvider.EXTERNAL_TASK_ERROR_MESSAGE)).body("[0].priority", equalTo(MockProvider.EXTERNAL_TASK_PRIORITY)).body("[0].variables." + MockProvider.EXAMPLE_VARIABLE_INSTANCE_NAME, notNullValue()).body("[0].variables." + MockProvider.EXAMPLE_VARIABLE_INSTANCE_NAME + ".value", equalTo(MockProvider.EXAMPLE_PRIMITIVE_VARIABLE_VALUE.getValue())).body("[0].variables." + MockProvider.EXAMPLE_VARIABLE_INSTANCE_NAME + ".type", equalTo("String")).when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE);
InOrder inOrder = inOrder(fetchTopicBuilder, externalTaskService);
inOrder.verify(externalTaskService).fetchAndLock(5, "aWorkerId", true);
inOrder.verify(fetchTopicBuilder).topic("aTopicName", 12354L);
inOrder.verify(fetchTopicBuilder).variables(Collections.singletonList(MockProvider.EXAMPLE_VARIABLE_INSTANCE_NAME));
inOrder.verify(fetchTopicBuilder).execute();
verifyNoMoreInteractions(fetchTopicBuilder, externalTaskService);
}
use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method createDto.
private FetchExternalTasksExtendedDto createDto(Long responseTimeout, boolean usePriority, boolean withVariables, boolean withDeserialization) {
FetchExternalTasksExtendedDto fetchExternalTasksDto = new FetchExternalTasksExtendedDto();
if (responseTimeout != null) {
fetchExternalTasksDto.setAsyncResponseTimeout(responseTimeout);
}
fetchExternalTasksDto.setMaxTasks(5);
fetchExternalTasksDto.setWorkerId("aWorkerId");
fetchExternalTasksDto.setUsePriority(usePriority);
FetchExternalTasksExtendedDto.FetchExternalTaskTopicDto topicDto = new FetchExternalTasksExtendedDto.FetchExternalTaskTopicDto();
fetchExternalTasksDto.setTopics(Collections.singletonList(topicDto));
topicDto.setTopicName("aTopicName");
topicDto.setLockDuration(12354L);
if (withVariables) {
topicDto.setVariables(Collections.singletonList(MockProvider.EXAMPLE_VARIABLE_INSTANCE_NAME));
}
topicDto.setDeserializeValues(withDeserialization);
fetchExternalTasksDto.setTopics(Collections.singletonList(topicDto));
return fetchExternalTasksDto;
}
Aggregations