Search in sources :

Example 6 with ProcessEngineException

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

the class TaskVariableLocalRestResourceInteractionTest method testGetLocalVariableForNonExistingTaskId.

@Test
public void testGetLocalVariableForNonExistingTaskId() {
    String variableKey = "aVariableKey";
    when(taskServiceMock.getVariableLocalTyped(eq(NON_EXISTING_ID), eq(variableKey), anyBoolean())).thenThrow(new ProcessEngineException("task " + NON_EXISTING_ID + " doesn't exist"));
    given().pathParam("id", NON_EXISTING_ID).pathParam("varId", variableKey).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot get task variable " + variableKey + ": task " + NON_EXISTING_ID + " doesn't exist")).when().get(SINGLE_TASK_SINGLE_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 7 with ProcessEngineException

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

the class TenantRestServiceInteractionTest method createExistingTenant.

@Test
public void createExistingTenant() {
    Tenant newTenant = MockProvider.createMockTenant();
    when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);
    String message = "exception expected";
    doThrow(new ProcessEngineException(message)).when(identityServiceMock).saveTenant(newTenant);
    given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(ProcessEngineException.class.getSimpleName())).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 8 with ProcessEngineException

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

the class UserRestServiceInteractionTest method testUserCreateExistingFails.

@Test
public void testUserCreateExistingFails() {
    User newUser = MockProvider.createMockUser();
    when(identityServiceMock.newUser(MockProvider.EXAMPLE_USER_ID)).thenReturn(newUser);
    doThrow(new ProcessEngineException("")).when(identityServiceMock).saveUser(newUser);
    UserDto userDto = UserDto.fromUser(newUser, true);
    given().body(userDto).contentType(ContentType.JSON).then().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(ProcessEngineException.class.getSimpleName())).when().post(USER_CREATE_URL);
    verify(identityServiceMock).newUser(MockProvider.EXAMPLE_USER_ID);
    verify(identityServiceMock).saveUser(newUser);
}
Also used : User(org.camunda.bpm.engine.identity.User) UserDto(org.camunda.bpm.engine.rest.dto.identity.UserDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 9 with ProcessEngineException

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

the class DeploymentRestServiceInteractionTest method testRedeployThrowsProcessEngineException.

@Test
public void testRedeployThrowsProcessEngineException() {
    String message = "something went wrong";
    doThrow(new ProcessEngineException(message)).when(mockDeploymentBuilder).deployWithResult();
    given().pathParam("id", MockProvider.EXAMPLE_DEPLOYMENT_ID).contentType(POST_JSON_CONTENT_TYPE).expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(ProcessEngineException.class.getSimpleName())).body("message", is(message)).when().post(REDEPLOY_DEPLOYMENT_URL);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 10 with ProcessEngineException

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

the class TaskRestServiceInteractionTest method testDeleteSingleTaskAttachmentForNonExistingAttachmentId.

@Test
public void testDeleteSingleTaskAttachmentForNonExistingAttachmentId() {
    doThrow(new ProcessEngineException()).when(taskServiceMock).deleteTaskAttachment(EXAMPLE_TASK_ID, NON_EXISTING_ID);
    given().pathParam("id", EXAMPLE_TASK_ID).pathParam("attachmentId", NON_EXISTING_ID).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body(containsString("Deletion is not possible. No attachment exists for task id '" + EXAMPLE_TASK_ID + "' and attachment id '" + NON_EXISTING_ID + "'.")).when().delete(SINGLE_TASK_DELETE_SINGLE_ATTACHMENT_URL);
}
Also used : 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