Search in sources :

Example 21 with ProcessEngineException

use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.

the class CaseDefinitionRestServiceInteractionTest method testCreateCaseInstanceByInvalidCaseDefinitionId.

@Test
public void testCreateCaseInstanceByInvalidCaseDefinitionId() {
    when(caseInstanceBuilder.create()).thenThrow(new ProcessEngineException("expected exception"));
    given().pathParam("id", MockProvider.EXAMPLE_CASE_DEFINITION_ID).contentType(POST_JSON_CONTENT_TYPE).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(RestException.class.getSimpleName())).body("message", containsString("Cannot instantiate case definition aCaseDefnitionId: expected exception")).when().post(CREATE_INSTANCE_URL);
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 22 with ProcessEngineException

use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.

the class CaseExecutionRestServiceInteractionTest method testPutLocalVariableForNonExistingExecution.

@Test
public void testPutLocalVariableForNonExistingExecution() {
    String variableKey = "aVariableKey";
    String variableValue = "aVariableValue";
    Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue);
    doThrow(new ProcessEngineException("expected exception")).when(caseExecutionCommandBuilderMock).execute();
    given().pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID).pathParam("varId", variableKey).contentType(ContentType.JSON).body(variableJson).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot put case execution variable " + variableKey + ": expected exception")).when().put(SINGLE_CASE_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) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 23 with ProcessEngineException

use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.

the class CaseExecutionRestServiceInteractionTest method testLocalVariableModificationForNonExistingExecution.

@Test
public void testLocalVariableModificationForNonExistingExecution() {
    when(caseServiceMock.withCaseExecution("aNonExistingExecutionId")).thenReturn(caseExecutionCommandBuilderMock);
    doThrow(new ProcessEngineException("expected exception")).when(caseExecutionCommandBuilderMock).execute();
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    String variableKey = "aKey";
    int variableValue = 123;
    Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
    messageBodyJson.put("modifications", modifications);
    given().pathParam("id", "aNonExistingExecutionId").contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("Cannot modify variables for case execution " + "aNonExistingExecutionId" + ": expected exception")).when().post(CASE_EXECUTION_LOCAL_VARIABLES_URL);
    Map<String, Object> expectedMap = new HashMap<String, Object>();
    expectedMap.put(variableKey, variableValue);
    verify(caseServiceMock).withCaseExecution("aNonExistingExecutionId");
    verify(caseExecutionCommandBuilderMock).removeVariablesLocal(null);
    verify(caseExecutionCommandBuilderMock).setVariablesLocal(eq(expectedMap));
    verify(caseExecutionCommandBuilderMock).execute();
}
Also used : HashMap(java.util.HashMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 24 with ProcessEngineException

use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.

the class CaseExecutionRestServiceInteractionTest method testGetLocalVariableForNonExistingExecution.

@Test
public void testGetLocalVariableForNonExistingExecution() {
    when(caseServiceMock.getVariableLocalTyped(eq(MockProvider.EXAMPLE_CASE_EXECUTION_ID), eq(EXAMPLE_VARIABLE_KEY), eq(true))).thenThrow(new ProcessEngineException("expected exception"));
    given().pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID).pathParam("varId", EXAMPLE_VARIABLE_KEY).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot get case execution variable " + EXAMPLE_VARIABLE_KEY + ": expected exception")).when().get(SINGLE_CASE_EXECUTION_LOCAL_VARIABLE_URL);
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 25 with ProcessEngineException

use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.

the class CaseExecutionRestServiceInteractionTest method testVariableModificationForNonExistingExecution.

@Test
public void testVariableModificationForNonExistingExecution() {
    when(caseServiceMock.withCaseExecution("aNonExistingExecutionId")).thenReturn(caseExecutionCommandBuilderMock);
    doThrow(new ProcessEngineException("expected exception")).when(caseExecutionCommandBuilderMock).execute();
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    String variableKey = "aKey";
    int variableValue = 123;
    Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
    messageBodyJson.put("modifications", modifications);
    given().pathParam("id", "aNonExistingExecutionId").contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("Cannot modify variables for case execution " + "aNonExistingExecutionId" + ": expected exception")).when().post(CASE_EXECUTION_VARIABLES_URL);
    Map<String, Object> expectedMap = new HashMap<String, Object>();
    expectedMap.put(variableKey, variableValue);
    verify(caseServiceMock).withCaseExecution("aNonExistingExecutionId");
    verify(caseExecutionCommandBuilderMock).removeVariables(null);
    verify(caseExecutionCommandBuilderMock).setVariables(eq(expectedMap));
    verify(caseExecutionCommandBuilderMock).execute();
}
Also used : HashMap(java.util.HashMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Aggregations

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)611 Test (org.junit.Test)185 Deployment (org.camunda.bpm.engine.test.Deployment)138 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)79 HashMap (java.util.HashMap)62 RestException (org.camunda.bpm.engine.rest.exception.RestException)62 Matchers.anyString (org.mockito.Matchers.anyString)60 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)57 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)47 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)41 Task (org.camunda.bpm.engine.task.Task)40 ArrayList (java.util.ArrayList)39 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)36 Matchers.containsString (org.hamcrest.Matchers.containsString)35 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)22 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)21 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)21 NotValidException (org.camunda.bpm.engine.exception.NotValidException)19 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18