Search in sources :

Example 21 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithNullProcessInstanceIdsAsync.

@Test
public void executeModificationWithNullProcessInstanceIdsAsync() {
    Map<String, Object> json = new HashMap<String, Object>();
    String message = "Process instance ids is null";
    doThrow(new BadUserRequestException(message)).when(modificationBuilderMock).executeAsync();
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.startAfter().activityId(EXAMPLE_ACTIVITY_ID).getJson());
    instructions.add(ModificationInstructionBuilder.startTransition().transitionId("transitionId").getJson());
    json.put("instructions", instructions);
    given().contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("message", is(message)).when().post(EXECUTE_MODIFICATION_ASYNC_URL);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 22 with BadUserRequestException

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

the class ProcessInstanceRestServiceInteractionTest method testDeleteAsyncHistoricQueryBasedWithoutQueryAndWithoutProcessInstanceIds.

@Test
public void testDeleteAsyncHistoricQueryBasedWithoutQueryAndWithoutProcessInstanceIds() {
    doThrow(new BadUserRequestException("processInstanceIds is empty")).when(runtimeServiceMock).deleteProcessInstancesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), anyString(), anyBoolean(), anyBoolean());
    given().contentType(ContentType.JSON).body(new DeleteProcessInstancesDto()).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(DELETE_PROCESS_INSTANCES_ASYNC_HIST_QUERY_URL);
    verify(runtimeServiceMock, times(1)).deleteProcessInstancesAsync(new ArrayList<String>(), null, null, false, false);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) DeleteProcessInstancesDto(org.camunda.bpm.engine.rest.dto.runtime.batch.DeleteProcessInstancesDto) Test(org.junit.Test)

Example 23 with BadUserRequestException

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

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessWithNegativeRetries.

@Test
public void testSetRetriesByProcessWithNegativeRetries() {
    doThrow(new BadUserRequestException("retries are negative")).when(mockManagementService).setJobRetriesAsync(anyListOf(String.class), any(ProcessInstanceQuery.class), eq(-1));
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put(RETRIES, -1);
    HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
    messageBodyJson.put("processInstanceQuery", query);
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_URL);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 24 with BadUserRequestException

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

the class ProcessInstanceRestServiceInteractionTest method testDeleteAsyncWithBadRequestQuery.

@Test
public void testDeleteAsyncWithBadRequestQuery() {
    doThrow(new BadUserRequestException("process instance ids are empty")).when(runtimeServiceMock).deleteProcessInstancesAsync(eq((List<String>) null), eq((ProcessInstanceQuery) null), anyString(), anyBoolean(), anyBoolean());
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("deleteReason", TEST_DELETE_REASON);
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(DELETE_PROCESS_INSTANCES_ASYNC_URL);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) HashMap(java.util.HashMap) List(java.util.List) EqualsList(org.camunda.bpm.engine.rest.helper.EqualsList) ArrayList(java.util.ArrayList) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 25 with BadUserRequestException

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

the class ResolveIncidentCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    final Incident incident = commandContext.getIncidentManager().findIncidentById(incidentId);
    EnsureUtil.ensureNotNull(NotFoundException.class, "Cannot find an incident with id '" + incidentId + "'", "incident", incident);
    if (incident.getIncidentType().equals("failedJob") || incident.getIncidentType().equals("failedExternalTask")) {
        throw new BadUserRequestException("Cannot resolve an incident of type " + incident.getIncidentType());
    }
    EnsureUtil.ensureNotNull(BadUserRequestException.class, "", "executionId", incident.getExecutionId());
    ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(incident.getExecutionId());
    EnsureUtil.ensureNotNull(BadUserRequestException.class, "Cannot find an execution for an incident with id '" + incidentId + "'", "execution", execution);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkUpdateProcessInstance(execution);
    }
    execution.resolveIncident(incidentId);
    return null;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Incident(org.camunda.bpm.engine.runtime.Incident) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

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