use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldThrowProcessEngineExceptionNotDuringTimeout.
@Test
public void shouldThrowProcessEngineExceptionNotDuringTimeout() {
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(500L);
when(fetchTopicBuilder.execute()).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, times(1)).execute();
}
use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldFetchWithCustomObjectDeserializationEnabled.
@Test
public void shouldFetchWithCustomObjectDeserializationEnabled() {
when(fetchTopicBuilder.execute()).thenReturn(new ArrayList<LockedExternalTask>(Collections.singleton(lockedExternalTaskMock)));
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(null, false, true, true);
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").then().expect().statusCode(Status.OK.getStatusCode()).when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE);
InOrder inOrder = inOrder(fetchTopicBuilder, externalTaskService);
inOrder.verify(externalTaskService).fetchAndLock(5, "aWorkerId", false);
inOrder.verify(fetchTopicBuilder).topic("aTopicName", 12354L);
inOrder.verify(fetchTopicBuilder).variables(Collections.singletonList(MockProvider.EXAMPLE_VARIABLE_INSTANCE_NAME));
inOrder.verify(fetchTopicBuilder).enableCustomObjectDeserialization();
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 shouldThrowInvalidRequestExceptionOnMaxTimeoutExceeded.
@Test
public void shouldThrowInvalidRequestExceptionOnMaxTimeoutExceeded() {
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(FetchAndLockHandlerImpl.MAX_TIMEOUT + 1);
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).pathParam("name", "default").then().expect().body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", containsString("The asynchronous response timeout cannot be set to a value greater than ")).statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(FETCH_EXTERNAL_TASK_URL_NAMED_ENGINE);
}
use of org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto in project camunda-bpm-platform by camunda.
the class FetchAndLockRestServiceInteractionTest method shouldFetchWithoutVariables.
@Test
public void shouldFetchWithoutVariables() {
when(fetchTopicBuilder.execute()).thenReturn(new ArrayList<LockedExternalTask>(Collections.singleton(lockedExternalTaskMock)));
FetchExternalTasksExtendedDto fetchExternalTasksDto = createDto(null);
given().contentType(ContentType.JSON).body(fetchExternalTasksDto).then().expect().statusCode(Status.OK.getStatusCode()).body("[0].id", equalTo(MockProvider.EXTERNAL_TASK_ID)).when().post(FETCH_EXTERNAL_TASK_URL);
InOrder inOrder = inOrder(fetchTopicBuilder, externalTaskService);
inOrder.verify(externalTaskService).fetchAndLock(5, "aWorkerId", false);
inOrder.verify(fetchTopicBuilder).topic("aTopicName", 12354L);
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 FetchAndLockHandlerTest method createDto.
protected FetchExternalTasksExtendedDto createDto(Long responseTimeout) {
FetchExternalTasksExtendedDto externalTask = new FetchExternalTasksExtendedDto();
FetchExternalTasksExtendedDto.FetchExternalTaskTopicDto topic = new FetchExternalTasksExtendedDto.FetchExternalTaskTopicDto();
topic.setTopicName("aTopicName");
topic.setLockDuration(12354L);
externalTask.setMaxTasks(5);
externalTask.setWorkerId("aWorkerId");
externalTask.setTopics(Collections.singletonList(topic));
if (responseTimeout != null) {
externalTask.setAsyncResponseTimeout(responseTimeout);
}
return externalTask;
}
Aggregations