Search in sources :

Example 31 with BadUserRequestException

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

the class HistoricBatchRestServiceInteractionTest method deleteNonExistingHistoricBatch.

@Test
public void deleteNonExistingHistoricBatch() {
    String nonExistingId = MockProvider.NON_EXISTING_ID;
    doThrow(new BadUserRequestException("Historic batch for id '" + nonExistingId + "' cannot be found")).when(historyServiceMock).deleteHistoricBatch(eq(nonExistingId));
    given().pathParam("id", nonExistingId).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Unable to delete historic batch with id '" + nonExistingId + "'")).when().delete(HISTORIC_SINGLE_BATCH_RESOURCE_URL);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 32 with BadUserRequestException

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

the class ExternalTaskRestServiceInteractionTest method testCompleteThrowsBadUserRequestException.

@Test
public void testCompleteThrowsBadUserRequestException() {
    doThrow(new BadUserRequestException("aMessage")).when(externalTaskService).complete(any(String.class), any(String.class), anyMapOf(String.class, Object.class), anyMapOf(String.class, Object.class));
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("workerId", "aWorkerId");
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("aMessage")).when().post(COMPLETE_EXTERNAL_TASK_URL);
}
Also used : HashMap(java.util.HashMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 33 with BadUserRequestException

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

the class ExternalTaskRestServiceInteractionTest method testHandleBpmnErrorThrowsBadUserRequestException.

@Test
public void testHandleBpmnErrorThrowsBadUserRequestException() {
    doThrow(new BadUserRequestException("aMessage")).when(externalTaskService).handleBpmnError(any(String.class), any(String.class), any(String.class));
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("workerId", "aWorkerId");
    parameters.put("errorCode", "errorCode");
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo("aMessage")).when().post(HANDLE_EXTERNAL_TASK_BPMN_ERROR_URL);
}
Also used : HashMap(java.util.HashMap) RestException(org.camunda.bpm.engine.rest.exception.RestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 34 with BadUserRequestException

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

the class BatchRestServiceInteractionTest method suspendNonExistingBatch.

@Test
public void suspendNonExistingBatch() {
    String nonExistingId = MockProvider.NON_EXISTING_ID;
    doThrow(new BadUserRequestException("Batch for id '" + nonExistingId + "' cannot be found")).when(managementServiceMock).suspendBatchById(eq(nonExistingId));
    given().pathParam("id", nonExistingId).contentType(ContentType.JSON).body(singletonMap("suspended", true)).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Unable to suspend batch with id '" + nonExistingId + "'")).when().put(SUSPENDED_BATCH_RESOURCE_URL);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 35 with BadUserRequestException

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

the class BatchRestServiceInteractionTest method deleteNonExistingBatch.

@Test
public void deleteNonExistingBatch() {
    String nonExistingId = MockProvider.NON_EXISTING_ID;
    doThrow(new BadUserRequestException("Batch for id '" + nonExistingId + "' cannot be found")).when(managementServiceMock).deleteBatch(eq(nonExistingId), eq(false));
    given().pathParam("id", nonExistingId).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Unable to delete batch with id '" + nonExistingId + "'")).when().delete(SINGLE_BATCH_RESOURCE_URL);
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Aggregations

BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)105 Test (org.junit.Test)68 Matchers.anyString (org.mockito.Matchers.anyString)43 HashMap (java.util.HashMap)22 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)19 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)16 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)16 ArrayList (java.util.ArrayList)14 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)13 Batch (org.camunda.bpm.engine.batch.Batch)12 Deployment (org.camunda.bpm.engine.test.Deployment)9 FluentAnswer (org.camunda.bpm.engine.rest.helper.FluentAnswer)8 JoinedMigrationPlanBuilderMock (org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock)8 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)8 Map (java.util.Map)7 RestException (org.camunda.bpm.engine.rest.exception.RestException)6 List (java.util.List)5 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)5 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5