Search in sources :

Example 1 with NotFoundException

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

the class ExternalTaskRestServiceImpl method setRetries.

@Override
public void setRetries(SetRetriesForExternalTasksDto retriesDto) {
    UpdateExternalTaskRetriesBuilder builder = updateRetries(retriesDto);
    int retries = retriesDto.getRetries();
    try {
        builder.set(retries);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e.getMessage());
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : UpdateExternalTaskRetriesBuilder(org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesBuilder) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 2 with NotFoundException

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

the class ProcessDefinitionRestServiceInteractionTest method testGetDeployedStartFormWithUnexistingForm.

@Test
public void testGetDeployedStartFormWithUnexistingForm() {
    String message = "not found";
    when(formServiceMock.getDeployedStartForm(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenThrow(new NotFoundException(message));
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("message", equalTo(message)).when().get(DEPLOYED_START_FORM_URL);
}
Also used : NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with NotFoundException

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

the class ProcessDefinitionRestServiceInteractionTest method testDeleteDefinitionsByKeyNotExistingKey.

@Test
public void testDeleteDefinitionsByKeyNotExistingKey() {
    DeleteProcessDefinitionsBuilder builder = repositoryServiceMock.deleteProcessDefinitions().byKey("NOT_EXISTING_KEY");
    doThrow(new NotFoundException("No process definition found with key 'NOT_EXISTING_KEY'")).when(builder).delete();
    given().pathParam("key", "NOT_EXISTING_KEY").expect().statusCode(Status.NOT_FOUND.getStatusCode()).body(containsString("No process definition found with key 'NOT_EXISTING_KEY'")).when().delete(SINGLE_PROCESS_DEFINITION_BY_KEY_DELETE_URL);
}
Also used : DeleteProcessDefinitionsBuilder(org.camunda.bpm.engine.repository.DeleteProcessDefinitionsBuilder) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) Test(org.junit.Test)

Example 4 with NotFoundException

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

the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionByKey_NotFound.

@Test
public void testEvaluateDecisionByKey_NotFound() {
    String message = "expected message";
    when(decisionEvaluationBuilderMock.evaluate()).thenThrow(new NotFoundException(message));
    Map<String, Object> json = new HashMap<String, Object>();
    json.put("variables", Collections.emptyMap());
    given().pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", is(InvalidRequestException.class.getSimpleName())).body("message", containsString(message)).when().post(EVALUATE_DECISION_BY_KEY_URL);
}
Also used : HashMap(java.util.HashMap) FileNotFoundException(java.io.FileNotFoundException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with NotFoundException

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

the class JobRestServiceInteractionTest method testSetJobPriorityNonExistentJob.

@Test
public void testSetJobPriorityNonExistentJob() {
    String expectedMessage = "No job found with id '" + MockProvider.NON_EXISTING_JOB_ID + "'.";
    doThrow(new NotFoundException(expectedMessage)).when(mockManagementService).setJobPriority(MockProvider.NON_EXISTING_JOB_ID, MockProvider.EXAMPLE_JOB_PRIORITY);
    Map<String, Object> priorityJson = new HashMap<String, Object>();
    priorityJson.put("priority", MockProvider.EXAMPLE_JOB_PRIORITY);
    given().pathParam("id", MockProvider.NON_EXISTING_JOB_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_RESOURCE_SET_PRIORITY_URL);
    verify(mockManagementService).setJobPriority(MockProvider.NON_EXISTING_JOB_ID, MockProvider.EXAMPLE_JOB_PRIORITY);
}
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)

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