Search in sources :

Example 41 with ProcessEngineException

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

the class JobDefinitionRestServiceInteractionTest method testSuspendJobDefinitionByProcessDefinitionIdWithException.

@Test
public void testSuspendJobDefinitionByProcessDefinitionIdWithException() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("suspended", true);
    params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
    String expectedException = "expectedException";
    doThrow(new ProcessEngineException(expectedException)).when(mockSuspensionStateBuilder).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(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 42 with ProcessEngineException

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

the class JobDefinitionRestServiceInteractionTest method testActivateJobDefinitionByProcessDefinitionIdWithException.

@Test
public void testActivateJobDefinitionByProcessDefinitionIdWithException() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("suspended", false);
    params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
    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)

Example 43 with ProcessEngineException

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

the class JobRestServiceInteractionTest method testExecuteJobIdDoesntExist.

@Test
public void testExecuteJobIdDoesntExist() {
    String jobId = MockProvider.NON_EXISTING_JOB_ID;
    String expectedMessage = "No job found with id '" + jobId + "'";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockManagementService).executeJob(MockProvider.NON_EXISTING_JOB_ID);
    given().pathParam("id", jobId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo(expectedMessage)).when().post(JOB_RESOURCE_EXECUTE_JOB_URL);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 44 with ProcessEngineException

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

the class JobRestServiceInteractionTest method testSetJobRetriesNonExistentJob.

@Test
public void testSetJobRetriesNonExistentJob() {
    String expectedMessage = "No job found with id '" + MockProvider.NON_EXISTING_JOB_ID + "'.";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockManagementService).setJobRetries(MockProvider.NON_EXISTING_JOB_ID, MockProvider.EXAMPLE_JOB_RETRIES);
    Map<String, Object> retriesVariableJson = new HashMap<String, Object>();
    retriesVariableJson.put("retries", MockProvider.EXAMPLE_JOB_RETRIES);
    given().pathParam("id", MockProvider.NON_EXISTING_JOB_ID).contentType(ContentType.JSON).body(retriesVariableJson).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo(expectedMessage)).when().put(JOB_RESOURCE_SET_RETRIES_URL);
    verify(mockManagementService).setJobRetries(MockProvider.NON_EXISTING_JOB_ID, MockProvider.EXAMPLE_JOB_RETRIES);
}
Also used : HashMap(java.util.HashMap) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 45 with ProcessEngineException

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

the class JobRestServiceInteractionTest method testActivateThrowsProcessEngineException.

@Test
public void testActivateThrowsProcessEngineException() {
    JobSuspensionStateDto dto = new JobSuspensionStateDto();
    dto.setSuspended(false);
    String expectedMessage = "expectedMessage";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockSuspensionStateBuilder).activate();
    given().pathParam("id", MockProvider.NON_EXISTING_JOB_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(ProcessEngineException.class.getSimpleName())).body("message", is(expectedMessage)).when().put(SINGLE_JOB_SUSPENDED_URL);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) JobSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.JobSuspensionStateDto) 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