Search in sources :

Example 1 with FetchExternalTasksExtendedDto

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();
}
Also used : FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 2 with FetchExternalTasksExtendedDto

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);
}
Also used : InOrder(org.mockito.InOrder) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 3 with FetchExternalTasksExtendedDto

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);
}
Also used : FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 4 with FetchExternalTasksExtendedDto

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);
}
Also used : InOrder(org.mockito.InOrder) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 5 with FetchExternalTasksExtendedDto

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;
}
Also used : FetchExternalTasksExtendedDto(org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto)

Aggregations

FetchExternalTasksExtendedDto (org.camunda.bpm.engine.rest.dto.externaltask.FetchExternalTasksExtendedDto)12 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)8 Test (org.junit.Test)8 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 InOrder (org.mockito.InOrder)3 IdentityService (org.camunda.bpm.engine.IdentityService)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)1 LockedExternalTaskDto (org.camunda.bpm.engine.rest.dto.externaltask.LockedExternalTaskDto)1 Ignore (org.junit.Ignore)1