Search in sources :

Example 1 with ProcessInstanceSuspensionStateDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testActivateThrowsProcessEngineException.

@Test
public void testActivateThrowsProcessEngineException() {
    ProcessInstanceSuspensionStateDto dto = new ProcessInstanceSuspensionStateDto();
    dto.setSuspended(false);
    String expectedMessage = "expectedMessage";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockUpdateSuspensionStateBuilder).activate();
    given().pathParam("id", MockProvider.EXAMPLE_NON_EXISTENT_PROCESS_INSTANCE_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_PROCESS_INSTANCE_SUSPENDED_URL);
}
Also used : ProcessInstanceSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 2 with ProcessInstanceSuspensionStateDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testActivateThrowsAuthorizationException.

@Test
public void testActivateThrowsAuthorizationException() {
    ProcessInstanceSuspensionStateDto dto = new ProcessInstanceSuspensionStateDto();
    dto.setSuspended(false);
    String message = "expectedMessage";
    doThrow(new AuthorizationException(message)).when(mockUpdateSuspensionStateBuilder).activate();
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(SINGLE_PROCESS_INSTANCE_SUSPENDED_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) ProcessInstanceSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto) Test(org.junit.Test)

Example 3 with ProcessInstanceSuspensionStateDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testActivateInstance.

@Test
public void testActivateInstance() {
    ProcessInstanceSuspensionStateDto dto = new ProcessInstanceSuspensionStateDto();
    dto.setSuspended(false);
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(SINGLE_PROCESS_INSTANCE_SUSPENDED_URL);
    verify(mockUpdateSuspensionStateSelectBuilder).byProcessInstanceId(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID);
    verify(mockUpdateSuspensionStateBuilder).activate();
}
Also used : ProcessInstanceSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto) Test(org.junit.Test)

Example 4 with ProcessInstanceSuspensionStateDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSuspendThrowsAuthorizationException.

@Test
public void testSuspendThrowsAuthorizationException() {
    ProcessInstanceSuspensionStateDto dto = new ProcessInstanceSuspensionStateDto();
    dto.setSuspended(true);
    String message = "expectedMessage";
    doThrow(new AuthorizationException(message)).when(mockUpdateSuspensionStateBuilder).suspend();
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(SINGLE_PROCESS_INSTANCE_SUSPENDED_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) ProcessInstanceSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto) Test(org.junit.Test)

Example 5 with ProcessInstanceSuspensionStateDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSuspendInstance.

@Test
public void testSuspendInstance() {
    ProcessInstanceSuspensionStateDto dto = new ProcessInstanceSuspensionStateDto();
    dto.setSuspended(true);
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(SINGLE_PROCESS_INSTANCE_SUSPENDED_URL);
    verify(mockUpdateSuspensionStateSelectBuilder).byProcessInstanceId(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID);
    verify(mockUpdateSuspensionStateBuilder).suspend();
}
Also used : ProcessInstanceSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto) Test(org.junit.Test)

Aggregations

ProcessInstanceSuspensionStateDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto)6 Test (org.junit.Test)6 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2