use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class BatchRestServiceInteractionTest method activateNonExistingBatch.
@Test
public void activateNonExistingBatch() {
String nonExistingId = MockProvider.NON_EXISTING_ID;
doThrow(new BadUserRequestException("Batch for id '" + nonExistingId + "' cannot be found")).when(managementServiceMock).activateBatchById(eq(nonExistingId));
given().pathParam("id", nonExistingId).contentType(ContentType.JSON).body(singletonMap("suspended", false)).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Unable to activate batch with id '" + nonExistingId + "'")).when().put(SUSPENDED_BATCH_RESOURCE_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class AbstractGetDeployedFormCmd method execute.
public InputStream execute(final CommandContext commandContext) {
checkAuthorization(commandContext);
final FormData formData = getFormData(commandContext);
String formKey = formData.getFormKey();
if (formKey == null) {
throw new BadUserRequestException("The form key is not set.");
}
final String resourceName = getResourceName(formKey);
try {
return commandContext.runWithoutAuthorization(new Callable<InputStream>() {
@Override
public InputStream call() throws Exception {
return new GetDeploymentResourceCmd(formData.getDeploymentId(), resourceName).execute(commandContext);
}
});
} catch (DeploymentResourceNotFoundException e) {
throw new NotFoundException("The form with the resource name '" + resourceName + "' cannot be found in deployment.", e);
}
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class ExternalTaskServiceTest method testExtendLockTimeWithDifferentWorkerId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testExtendLockTimeWithDifferentWorkerId() {
// given
runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
List<LockedExternalTask> lockedTasks = externalTaskService.fetchAndLock(1, WORKER_ID).topic(TOPIC_NAME, 1L).execute();
assertNotNull(lockedTasks);
assertEquals(1, lockedTasks.size());
LockedExternalTask task = lockedTasks.get(0);
// when
try {
externalTaskService.extendLock(task.getId(), "anAnotherWorkerId", 100);
fail("Exception expected");
} catch (BadUserRequestException e) {
assertTrue(e.getMessage().contains("The lock of the External Task " + task.getId() + " cannot be extended by worker 'anAnotherWorkerId'"));
}
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldFailForNullExternalTaskIdAsync.
@Test
public void shouldFailForNullExternalTaskIdAsync() {
List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
ArrayList<String> externalTaskIds = new ArrayList<String>();
for (ExternalTask task : externalTasks) {
externalTaskIds.add(task.getId());
}
externalTaskIds.add(null);
Batch batch = null;
try {
batch = externalTaskService.setRetriesAsync(externalTaskIds, null, 10);
executeSeedAndBatchJobs(batch);
fail("exception expected");
} catch (BadUserRequestException e) {
Assert.assertThat(e.getMessage(), containsString("External task id cannot be null"));
}
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class SetExternalTasksRetriesTest method shouldFailForNullExternalTaskIdSync.
@Test
public void shouldFailForNullExternalTaskIdSync() {
List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
ArrayList<String> externalTaskIds = new ArrayList<String>();
for (ExternalTask task : externalTasks) {
externalTaskIds.add(task.getId());
}
externalTaskIds.add(null);
try {
externalTaskService.setRetries(externalTaskIds, 10);
fail("exception expected");
} catch (BadUserRequestException e) {
Assert.assertThat(e.getMessage(), containsString("External task id cannot be null"));
}
}
Aggregations