Search in sources :

Example 1 with JobSuspensionStateDto

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

the class JobRestServiceInteractionTest method testActivateJob.

@Test
public void testActivateJob() {
    JobSuspensionStateDto dto = new JobSuspensionStateDto();
    dto.setSuspended(false);
    given().pathParam("id", MockProvider.EXAMPLE_JOB_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(SINGLE_JOB_SUSPENDED_URL);
    verify(mockSuspensionStateSelectBuilder).byJobId(MockProvider.EXAMPLE_JOB_ID);
    verify(mockSuspensionStateBuilder).activate();
}
Also used : JobSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.JobSuspensionStateDto) Test(org.junit.Test)

Example 2 with JobSuspensionStateDto

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

the class JobRestServiceInteractionTest method testSuspendJob.

@Test
public void testSuspendJob() {
    JobSuspensionStateDto dto = new JobSuspensionStateDto();
    dto.setSuspended(true);
    given().pathParam("id", MockProvider.EXAMPLE_JOB_ID).contentType(ContentType.JSON).body(dto).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(SINGLE_JOB_SUSPENDED_URL);
    verify(mockSuspensionStateSelectBuilder).byJobId(MockProvider.EXAMPLE_JOB_ID);
    verify(mockSuspensionStateBuilder).suspend();
}
Also used : JobSuspensionStateDto(org.camunda.bpm.engine.rest.dto.runtime.JobSuspensionStateDto) Test(org.junit.Test)

Example 3 with JobSuspensionStateDto

use of org.camunda.bpm.engine.rest.dto.runtime.JobSuspensionStateDto 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)

Example 4 with JobSuspensionStateDto

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

the class JobRestServiceInteractionTest method testActivateThrowsAuthorizationException.

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

Example 5 with JobSuspensionStateDto

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

the class JobRestServiceInteractionTest method testSuspendedThrowsProcessEngineException.

@Test
public void testSuspendedThrowsProcessEngineException() {
    JobSuspensionStateDto dto = new JobSuspensionStateDto();
    dto.setSuspended(true);
    String expectedMessage = "expectedMessage";
    doThrow(new ProcessEngineException(expectedMessage)).when(mockSuspensionStateBuilder).suspend();
    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

JobSuspensionStateDto (org.camunda.bpm.engine.rest.dto.runtime.JobSuspensionStateDto)6 Test (org.junit.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)4 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2