use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class TaskQueryTest method testInitializeFormKeys.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/task/oneTaskWithFormKeyProcess.bpmn20.xml" })
public void testInitializeFormKeys() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
// if initializeFormKeys
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).initializeFormKeys().singleResult();
// then the form key is present
assertEquals("exampleFormKey", task.getFormKey());
// if NOT initializeFormKeys
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
try {
// then the form key is not retrievable
task.getFormKey();
fail("exception expected.");
} catch (BadUserRequestException e) {
assertEquals("ENGINE-03052 The form key is not initialized. You must call initializeFormKeys() on the task query before you can retrieve the form key.", e.getMessage());
}
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class SignalRestServiceTest method shouldThrowBadUserRequestException.
@Test
public void shouldThrowBadUserRequestException() {
String message = "expected exception";
doThrow(new BadUserRequestException(message)).when(signalBuilderMock).send();
Map<String, Object> requestBody = new HashMap<String, Object>();
requestBody.put("name", "aSignalName");
given().contentType(POST_JSON_CONTENT_TYPE).body(requestBody).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(BadUserRequestException.class.getSimpleName())).body("message", equalTo(message)).when().post(SIGNAL_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceRestServiceInteractionTest method testDeleteAsyncWithBadRequestQuery.
@Test
public void testDeleteAsyncWithBadRequestQuery() {
doThrow(new BadUserRequestException("process instance ids are empty")).when(historyServiceMock).deleteHistoricProcessInstancesAsync(eq((List<String>) null), eq((HistoricProcessInstanceQuery) null), anyString());
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put(DELETE_REASON, TEST_DELETE_REASON);
given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(DELETE_HISTORIC_PROCESS_INSTANCES_ASYNC_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceInteractionTest method testCreateIncidentWithNullIncidentType.
@Test
public void testCreateIncidentWithNullIncidentType() {
doThrow(new BadUserRequestException()).when(runtimeServiceMock).createIncident(anyString(), anyString(), anyString(), anyString());
Map<String, Object> json = new HashMap<String, Object>();
json.put("configuration", "configuration");
json.put("message", "message");
given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(CREATE_INCIDENT_URL);
}
use of org.camunda.bpm.engine.BadUserRequestException in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceInteractionTest method testPutLocalVariableForNonExistingExecution.
@Test
public void testPutLocalVariableForNonExistingExecution() {
String variableKey = "aVariableKey";
String variableValue = "aVariableValue";
Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue);
doThrow(new BadUserRequestException("expected exception")).when(runtimeServiceMock).setVariableLocal(eq(MockProvider.EXAMPLE_EXECUTION_ID), eq(variableKey), any());
given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).pathParam("varId", variableKey).contentType(ContentType.JSON).body(variableJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot put execution variable " + variableKey + ": expected exception")).when().put(SINGLE_EXECUTION_LOCAL_VARIABLE_URL);
}
Aggregations