Search in sources :

Example 11 with NotFoundException

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

the class ExternalTaskRestServiceInteractionTest method testHandleBpmnErrorNonExistingTask.

@Test
public void testHandleBpmnErrorNonExistingTask() {
    doThrow(new NotFoundException()).when(externalTaskService).handleBpmnError(any(String.class), any(String.class), any(String.class));
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("workerId", "aWorkerId");
    parameters.put("errorCode", "errorCode");
    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_BPMN_ERROR_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)

Example 12 with NotFoundException

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

the class ExternalTaskRestServiceInteractionTest method testGetErrorDetailsNonExistingTask.

@Test
public void testGetErrorDetailsNonExistingTask() {
    doThrow(new NotFoundException()).when(externalTaskService).getExternalTaskErrorDetails(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().get(GET_EXTERNAL_TASK_ERROR_DETAILS_URL);
    verify(externalTaskService).getExternalTaskErrorDetails("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 13 with NotFoundException

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

the class ExternalTaskRestServiceInteractionTest method testSetPriorityNonExistingTask.

@Test
public void testSetPriorityNonExistingTask() {
    doThrow(new NotFoundException()).when(externalTaskService).setPriority(any(String.class), anyInt());
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("priority", "5");
    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().put(PRIORITY_EXTERNAL_TASK_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)

Example 14 with NotFoundException

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

the class CaseDefinitionResourceImpl method getCaseDefinition.

@Override
public CaseDefinitionDto getCaseDefinition() {
    RepositoryService repositoryService = engine.getRepositoryService();
    CaseDefinition definition = null;
    try {
        definition = repositoryService.getCaseDefinition(caseDefinitionId);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    }
    return CaseDefinitionDto.fromCaseDefinition(definition);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 15 with NotFoundException

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

the class DecisionRequirementsDefinitionResourceImpl method getDecisionRequirementsDefinition.

@Override
public DecisionRequirementsDefinitionDto getDecisionRequirementsDefinition() {
    RepositoryService repositoryService = engine.getRepositoryService();
    DecisionRequirementsDefinition definition = null;
    try {
        definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
    }
    return DecisionRequirementsDefinitionDto.fromDecisionRequirementsDefinition(definition);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) DecisionRequirementsDefinition(org.camunda.bpm.engine.repository.DecisionRequirementsDefinition) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RepositoryService(org.camunda.bpm.engine.RepositoryService)

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