use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceInteractionTest method testDeleteNonExistingDeployment.
@Test
public void testDeleteNonExistingDeployment() {
doThrow(new NotFoundException("No process definition found with id 'NON_EXISTING_ID'")).when(repositoryServiceMock).deleteProcessDefinition("NON_EXISTING_ID", false, false);
given().pathParam("id", "NON_EXISTING_ID").expect().statusCode(Status.NOT_FOUND.getStatusCode()).body(containsString("No process definition found with id 'NON_EXISTING_ID'")).when().delete(SINGLE_PROCESS_DEFINITION_URL);
}
use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesNonExistingTask.
@Test
public void testSetRetriesNonExistingTask() {
doThrow(new NotFoundException()).when(externalTaskService).setRetries(any(String.class), anyInt());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("retries", "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(RETRIES_EXTERNAL_TASK_URL);
}
use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testCompleteNonExistingTask.
@Test
public void testCompleteNonExistingTask() {
doThrow(new NotFoundException()).when(externalTaskService).complete(any(String.class), any(String.class), anyMapOf(String.class, Object.class), anyMapOf(String.class, Object.class));
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("workerId", "aWorkerId");
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(COMPLETE_EXTERNAL_TASK_URL);
}
use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.
the class CaseDefinitionResourceImpl method getCaseDefinitionCmmnXml.
@Override
public CaseDefinitionDiagramDto getCaseDefinitionCmmnXml() {
InputStream caseModelInputStream = null;
try {
caseModelInputStream = engine.getRepositoryService().getCaseModel(caseDefinitionId);
byte[] caseModel = IoUtil.readInputStream(caseModelInputStream, "caseModelCmmnXml");
return CaseDefinitionDiagramDto.create(caseDefinitionId, new String(caseModel, "UTF-8"));
} 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);
} catch (UnsupportedEncodingException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
} finally {
IoUtil.closeSilently(caseModelInputStream);
}
}
use of org.camunda.bpm.engine.exception.NotFoundException in project camunda-bpm-platform by camunda.
the class CaseDefinitionResourceImpl method createCaseInstance.
public CaseInstanceDto createCaseInstance(UriInfo context, CreateCaseInstanceDto parameters) {
CaseService caseService = engine.getCaseService();
CaseInstance instance = null;
try {
String businessKey = parameters.getBusinessKey();
VariableMap variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
instance = caseService.withCaseDefinition(caseDefinitionId).businessKey(businessKey).setVariables(variables).create();
} catch (RestException e) {
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
throw new InvalidRequestException(e.getStatus(), e, errorMessage);
} catch (NotFoundException e) {
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.NOT_FOUND, e, errorMessage);
} catch (NotValidException e) {
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.BAD_REQUEST, e, errorMessage);
} catch (NotAllowedException e) {
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);
} catch (ProcessEngineException e) {
String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
}
CaseInstanceDto result = CaseInstanceDto.fromCaseInstance(instance);
URI uri = context.getBaseUriBuilder().path(rootResourcePath).path(CaseInstanceRestService.PATH).path(instance.getId()).build();
result.addReflexiveLink(uri, HttpMethod.GET, "self");
return result;
}
Aggregations