Search in sources :

Example 86 with BadUserRequestException

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

the class RepositoryServiceTest method testProcessDefinitionUpdateTimeToLiveNegative.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testProcessDefinitionUpdateTimeToLiveNegative() {
    // given
    ProcessDefinition processDefinition = findOnlyProcessDefinition();
    // when
    try {
        repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinition.getId(), -1);
        fail("Exception is expected, that negative value is not allowed.");
    } catch (BadUserRequestException ex) {
        assertTrue(ex.getMessage().contains("greater than"));
    }
}
Also used : ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 87 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithNullProcessDefinitionIdSync.

@Test
public void executeModificationWithNullProcessDefinitionIdSync() {
    doThrow(new BadUserRequestException("processDefinitionId must be set")).when(modificationBuilderMock).execute();
    Map<String, Object> json = new HashMap<String, Object>();
    json.put("skipCustomListeners", true);
    json.put("skipIoMappings", true);
    json.put("processInstanceIds", Arrays.asList("100", "20"));
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.cancellation().activityId("activityId").getJson());
    instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").getJson());
    instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").getJson());
    instructions.add(ModificationInstructionBuilder.startTransition().transitionId("transitionId").getJson());
    json.put("instructions", instructions);
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(EXECUTE_MODIFICATION_SYNC_URL);
    verify(runtimeServiceMock).createModification(null);
    verify(modificationBuilderMock).processInstanceIds(eq(Arrays.asList("100", "20")));
    verify(modificationBuilderMock).cancelAllForActivity("activityId");
    verify(modificationBuilderMock).startBeforeActivity("activityId");
    verify(modificationBuilderMock).startAfterActivity("activityId");
    verify(modificationBuilderMock).startTransition("transitionId");
    verify(modificationBuilderMock).skipCustomListeners();
    verify(modificationBuilderMock).skipIoMappings();
    verify(modificationBuilderMock).execute();
}
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 88 with BadUserRequestException

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

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithBadRequestQuery.

@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithBadRequestQuery() {
    doThrow(new BadUserRequestException("jobIds is empty")).when(mockManagementService).setJobRetriesAsync(eq(new ArrayList<String>()), eq((ProcessInstanceQuery) null), anyInt());
    SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
    body.setRetries(MockProvider.EXAMPLE_JOB_RETRIES);
    given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_URL);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ArrayList(java.util.ArrayList) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 89 with BadUserRequestException

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

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessAsyncHistoricQueryBasedWithNegativeRetries.

@Test
public void testSetRetriesByProcessAsyncHistoricQueryBasedWithNegativeRetries() {
    doThrow(new BadUserRequestException("retries are negative")).when(mockManagementService).setJobRetriesAsync(anyListOf(String.class), eq((ProcessInstanceQuery) null), eq(MockProvider.EXAMPLE_NEGATIVE_JOB_RETRIES));
    HistoricProcessInstanceQuery mockedHistoricProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(mockedHistoricProcessInstanceQuery);
    List<HistoricProcessInstance> historicProcessInstances = MockProvider.createMockRunningHistoricProcessInstances();
    when(mockedHistoricProcessInstanceQuery.list()).thenReturn(historicProcessInstances);
    SetJobRetriesByProcessDto body = new SetJobRetriesByProcessDto();
    body.setRetries(MockProvider.EXAMPLE_NEGATIVE_JOB_RETRIES);
    body.setHistoricProcessInstanceQuery(new HistoricProcessInstanceQueryDto());
    given().contentType(ContentType.JSON).body(body).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_ASYNC_HIST_QUERY_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) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) SetJobRetriesByProcessDto(org.camunda.bpm.engine.rest.dto.runtime.SetJobRetriesByProcessDto) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Test(org.junit.Test)

Example 90 with BadUserRequestException

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

the class ProcessInstanceRestServiceInteractionTest method testSetRetriesByProcessWithBadRequestQuery.

@Test
public void testSetRetriesByProcessWithBadRequestQuery() {
    doThrow(new BadUserRequestException("job ids are empty")).when(mockManagementService).setJobRetriesAsync(eq((List<String>) null), eq((ProcessInstanceQuery) null), anyInt());
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put(RETRIES, 5);
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(SET_JOB_RETRIES_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)

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