Search in sources :

Example 56 with BadUserRequestException

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());
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 57 with BadUserRequestException

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);
}
Also used : HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 58 with BadUserRequestException

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);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HashMap(java.util.HashMap) List(java.util.List) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 59 with BadUserRequestException

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);
}
Also used : HashMap(java.util.HashMap) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 60 with BadUserRequestException

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);
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Aggregations

BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)105 Test (org.junit.Test)68 Matchers.anyString (org.mockito.Matchers.anyString)43 HashMap (java.util.HashMap)22 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)19 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)16 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)16 ArrayList (java.util.ArrayList)14 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)13 Batch (org.camunda.bpm.engine.batch.Batch)12 Deployment (org.camunda.bpm.engine.test.Deployment)9 FluentAnswer (org.camunda.bpm.engine.rest.helper.FluentAnswer)8 JoinedMigrationPlanBuilderMock (org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock)8 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)8 Map (java.util.Map)7 RestException (org.camunda.bpm.engine.rest.exception.RestException)6 List (java.util.List)5 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)5 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5