use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testHandleFailureThrowsBadUserRequestException.
@Test
public void testHandleFailureThrowsBadUserRequestException() {
doThrow(new BadUserRequestException("aMessage")).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.BAD_REQUEST.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("aMessage")).when().post(HANDLE_EXTERNAL_TASK_FAILURE_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class BatchRestServiceInteractionTest method deleteNonExistingBatchNotCascade.
@Test
public void deleteNonExistingBatchNotCascade() {
String nonExistingId = MockProvider.NON_EXISTING_ID;
doThrow(new BadUserRequestException("Batch for id '" + nonExistingId + "' cannot be found")).when(managementServiceMock).deleteBatch(eq(nonExistingId), eq(false));
given().pathParam("id", nonExistingId).queryParam("cascade", false).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Unable to delete batch with id '" + nonExistingId + "'")).when().delete(SINGLE_BATCH_RESOURCE_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class BatchRestServiceInteractionTest method deleteNonExistingBatchCascade.
@Test
public void deleteNonExistingBatchCascade() {
String nonExistingId = MockProvider.NON_EXISTING_ID;
doThrow(new BadUserRequestException("Batch for id '" + nonExistingId + "' cannot be found")).when(managementServiceMock).deleteBatch(eq(nonExistingId), eq(true));
given().pathParam("id", nonExistingId).queryParam("cascade", true).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Unable to delete batch with id '" + nonExistingId + "'")).when().delete(SINGLE_BATCH_RESOURCE_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class AbstractVariablesResource method putVariable.
@Override
public void putVariable(String variableName, VariableValueDto variable) {
try {
TypedValue typedValue = variable.toTypedValue(engine, objectMapper);
setVariableEntity(variableName, typedValue);
} catch (RestException e) {
throw new InvalidRequestException(e.getStatus(), e, String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableName, e.getMessage()));
} catch (BadUserRequestException e) {
throw new RestException(Status.BAD_REQUEST, e, String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableName, e.getMessage()));
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableName, e.getMessage()));
}
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceImpl method setRetriesByProcessHistoricQueryBased.
@Override
public BatchDto setRetriesByProcessHistoricQueryBased(SetJobRetriesByProcessDto setJobRetriesDto) {
List<String> processInstanceIds = new ArrayList<String>();
HistoricProcessInstanceQueryDto queryDto = setJobRetriesDto.getHistoricProcessInstanceQuery();
if (queryDto != null) {
HistoricProcessInstanceQuery query = queryDto.toQuery(getProcessEngine());
List<HistoricProcessInstance> historicProcessInstances = query.list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
processInstanceIds.add(historicProcessInstance.getId());
}
}
if (setJobRetriesDto.getProcessInstances() != null) {
processInstanceIds.addAll(setJobRetriesDto.getProcessInstances());
}
try {
ManagementService managementService = getProcessEngine().getManagementService();
Batch batch = managementService.setJobRetriesAsync(processInstanceIds, (ProcessInstanceQuery) null, setJobRetriesDto.getRetries());
return BatchDto.fromBatch(batch);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}
Aggregations