Search in sources :

Example 36 with ProcessEngineException

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

the class ProcessInstanceRestServiceInteractionTest method testDeleteNonExistingProcessInstance.

@Test
public void testDeleteNonExistingProcessInstance() {
    doThrow(new ProcessEngineException("expected exception")).when(runtimeServiceMock).deleteProcessInstance(anyString(), anyString(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Process instance with id " + MockProvider.EXAMPLE_PROCESS_INSTANCE_ID + " does not exist")).when().delete(SINGLE_PROCESS_INSTANCE_URL);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 37 with ProcessEngineException

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

the class ProcessInstanceRestServiceInteractionTest method testSuspendProcessInstanceByProcessDefinitionKeyWithException.

@Test
public void testSuspendProcessInstanceByProcessDefinitionKeyWithException() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("suspended", true);
    params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY);
    String expectedException = "expectedException";
    doThrow(new ProcessEngineException(expectedException)).when(mockUpdateSuspensionStateBuilder).suspend();
    given().contentType(ContentType.JSON).body(params).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(ProcessEngineException.class.getSimpleName())).body("message", is(expectedException)).when().put(PROCESS_INSTANCE_SUSPENDED_URL);
}
Also used : HashMap(java.util.HashMap) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 38 with ProcessEngineException

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

the class JobDefinitionRestServiceInteractionTest method testSuspendThrowsProcessEngineException.

@Test
public void testSuspendThrowsProcessEngineException() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("suspended", true);
    params.put("includeJobs", false);
    String expectedMessage = "expectedMessage";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockSuspensionStateBuilder).suspend();
    given().pathParam("id", MockProvider.NON_EXISTING_JOB_DEFINITION_ID).contentType(ContentType.JSON).body(params).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(ProcessEngineException.class.getSimpleName())).body("message", is(expectedMessage)).when().put(SINGLE_JOB_DEFINITION_SUSPENDED_URL);
}
Also used : HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 39 with ProcessEngineException

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

the class JobDefinitionRestServiceInteractionTest method testSetJobPriorityExceptionExpected.

@Test
public void testSetJobPriorityExceptionExpected() {
    String expectedMessage = "expected exception message";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockManagementService).setOverridingJobPriorityForJobDefinition(eq(MockProvider.EXAMPLE_JOB_DEFINITION_ID), eq(MockProvider.EXAMPLE_JOB_DEFINITION_PRIORITY), anyBoolean());
    Map<String, Object> priorityJson = new HashMap<String, Object>();
    priorityJson.put("priority", MockProvider.EXAMPLE_JOB_DEFINITION_PRIORITY);
    given().pathParam("id", MockProvider.EXAMPLE_JOB_DEFINITION_ID).contentType(ContentType.JSON).body(priorityJson).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo(expectedMessage)).when().put(JOB_DEFINITION_PRIORITY_URL);
    verify(mockManagementService).setOverridingJobPriorityForJobDefinition(MockProvider.EXAMPLE_JOB_DEFINITION_ID, MockProvider.EXAMPLE_JOB_DEFINITION_PRIORITY, false);
}
Also used : HashMap(java.util.HashMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 40 with ProcessEngineException

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

the class JobDefinitionRestServiceInteractionTest method testActivateJobDefinitionByProcessDefinitionKeyWithException.

@Test
public void testActivateJobDefinitionByProcessDefinitionKeyWithException() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("suspended", false);
    params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY);
    String expectedException = "expectedException";
    doThrow(new ProcessEngineException(expectedException)).when(mockSuspensionStateBuilder).activate();
    given().contentType(ContentType.JSON).body(params).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(ProcessEngineException.class.getSimpleName())).body("message", is(expectedException)).when().put(JOB_DEFINITION_SUSPENDED_URL);
}
Also used : HashMap(java.util.HashMap) 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