Search in sources :

Example 1 with BadUserRequestException

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

the class ExternalTaskRestServiceImpl method setRetries.

@Override
public void setRetries(SetRetriesForExternalTasksDto retriesDto) {
    UpdateExternalTaskRetriesBuilder builder = updateRetries(retriesDto);
    int retries = retriesDto.getRetries();
    try {
        builder.set(retries);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e.getMessage());
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : UpdateExternalTaskRetriesBuilder(org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesBuilder) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 2 with BadUserRequestException

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

the class RestartProcessInstanceRestServiceTest method testRestartProcessInstanceWithNullProcessInstanceIdsSync.

@Test
public void testRestartProcessInstanceWithNullProcessInstanceIdsSync() {
    doThrow(new BadUserRequestException("processInstanceIds is null")).when(builderMock).execute();
    HashMap<String, Object> json = new HashMap<String, Object>();
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").getJson());
    json.put("instructions", instructions);
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(RESTART_PROCESS_INSTANCE_URL);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.anyString(org.mockito.Matchers.anyString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with BadUserRequestException

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

the class MigrationRestServiceInteractionTest method executeMigrationPlanWithNonExistingTargetActivityId.

@Test
public void executeMigrationPlanWithNonExistingTargetActivityId() {
    String message = "targetActivity is null";
    when(migrationPlanBuilderMock.mapActivities(anyString(), eq(NON_EXISTING_ACTIVITY_ID))).thenThrow(new BadUserRequestException(message));
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(EXAMPLE_ACTIVITY_ID, NON_EXISTING_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID).done().processInstances(EXAMPLE_PROCESS_INSTANCE_ID, ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("message", is(message)).when().post(EXECUTE_MIGRATION_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 4 with BadUserRequestException

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

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNullTargetProcessDefinitionId.

@Test
public void executeMigrationPlanAsyncWithNullTargetProcessDefinitionId() {
    String message = "target process definition id is null";
    JoinedMigrationPlanBuilderMock migrationPlanBuilder = mock(JoinedMigrationPlanBuilderMock.class, new FluentAnswer());
    when(runtimeServiceMock.createMigrationPlan(anyString(), isNull(String.class))).thenReturn(migrationPlanBuilder);
    when(migrationPlanBuilder.build()).thenThrow(new BadUserRequestException(message));
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, null).instruction(EXAMPLE_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID).done().processInstances(EXAMPLE_PROCESS_INSTANCE_ID, ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("message", is(message)).when().post(EXECUTE_MIGRATION_ASYNC_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) FluentAnswer(org.camunda.bpm.engine.rest.helper.FluentAnswer) JoinedMigrationPlanBuilderMock(org.camunda.bpm.engine.rest.helper.MockMigrationPlanBuilder.JoinedMigrationPlanBuilderMock) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 5 with BadUserRequestException

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

the class MigrationRestServiceInteractionTest method executeMigrationPlanAsyncWithNonExistingSourceActivityId.

@Test
public void executeMigrationPlanAsyncWithNonExistingSourceActivityId() {
    String message = "sourceActivity is null";
    when(migrationPlanBuilderMock.mapActivities(eq(NON_EXISTING_ACTIVITY_ID), anyString())).thenThrow(new BadUserRequestException(message));
    Map<String, Object> migrationExecution = new MigrationExecutionDtoBuilder().migrationPlan(EXAMPLE_PROCESS_DEFINITION_ID, ANOTHER_EXAMPLE_PROCESS_DEFINITION_ID).instruction(NON_EXISTING_ACTIVITY_ID, ANOTHER_EXAMPLE_ACTIVITY_ID).instruction(ANOTHER_EXAMPLE_ACTIVITY_ID, EXAMPLE_ACTIVITY_ID).done().processInstances(EXAMPLE_PROCESS_INSTANCE_ID, ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID).build();
    given().contentType(POST_JSON_CONTENT_TYPE).body(migrationExecution).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("message", is(message)).when().post(EXECUTE_MIGRATION_ASYNC_URL);
}
Also used : MigrationExecutionDtoBuilder(org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder) Matchers.anyString(org.mockito.Matchers.anyString) 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