Search in sources :

Example 6 with NotFoundException

use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.

the class IncidentRestServiceInteractionTest method testResolveUnexistingIncident.

@Test
public void testResolveUnexistingIncident() {
    doThrow(new NotFoundException()).when(mockRuntimeService).resolveIncident(anyString());
    given().pathParam("id", MockProvider.EXAMPLE_INCIDENT_ID).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).when().delete(SINGLE_INCIDENT_URL);
    verify(mockRuntimeService).resolveIncident(MockProvider.EXAMPLE_INCIDENT_ID);
}
Also used : NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) Test(org.junit.Test)

Example 7 with NotFoundException

use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.

the class JobDefinitionRestServiceInteractionTest method testSetNonExistingJobDefinitionPriority.

@Test
public void testSetNonExistingJobDefinitionPriority() {
    String expectedMessage = "expected exception message";
    doThrow(new NotFoundException(expectedMessage)).when(mockManagementService).setOverridingJobPriorityForJobDefinition(eq(MockProvider.NON_EXISTING_JOB_DEFINITION_ID), eq(MockProvider.EXAMPLE_JOB_DEFINITION_PRIORITY), anyBoolean());
    Map<String, Object> priorityJson = new HashMap<String, Object>();
    priorityJson.put("priority", MockProvider.EXAMPLE_JOB_DEFINITION_PRIORITY);
    given().pathParam("id", MockProvider.NON_EXISTING_JOB_DEFINITION_ID).contentType(ContentType.JSON).body(priorityJson).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo(expectedMessage)).when().put(JOB_DEFINITION_PRIORITY_URL);
}
Also used : HashMap(java.util.HashMap) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with NotFoundException

use of org.camunda.bpm.engine.exception.NotFoundException 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());
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 9 with NotFoundException

use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method testUnlockNonExistingTask.

@Test
public void testUnlockNonExistingTask() {
    doThrow(new NotFoundException()).when(externalTaskService).unlock(any(String.class));
    given().pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("External task with id anExternalTaskId does not exist")).when().post(UNLOCK_EXTERNAL_TASK_URL);
    verify(externalTaskService).unlock("anExternalTaskId");
    verifyNoMoreInteractions(externalTaskService);
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with NotFoundException

use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method testHandleFailureNonExistingTask.

@Test
public void testHandleFailureNonExistingTask() {
    doThrow(new NotFoundException()).when(externalTaskService).handleFailure(any(String.class), any(String.class), any(String.class), any(String.class), anyInt(), anyLong());
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("workerId", "aWorkerId");
    parameters.put("errorMessage", "anErrorMessage");
    parameters.put("retries", 5);
    parameters.put("retryTimeout", 12345);
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("External task with id anExternalTaskId does not exist")).when().post(HANDLE_EXTERNAL_TASK_FAILURE_URL);
}
Also used : HashMap(java.util.HashMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)44 Test (org.junit.Test)20 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 NotValidException (org.camunda.bpm.engine.exception.NotValidException)17 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)17 RestException (org.camunda.bpm.engine.rest.exception.RestException)17 Matchers.anyString (org.mockito.Matchers.anyString)15 HashMap (java.util.HashMap)11 CaseService (org.camunda.bpm.engine.CaseService)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 InputStream (java.io.InputStream)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 RepositoryService (org.camunda.bpm.engine.RepositoryService)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 FileNotFoundException (java.io.FileNotFoundException)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2