Search in sources :

Example 16 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithNullProcessInstanceIdsSync.

@Test
public void executeModificationWithNullProcessInstanceIdsSync() {
    Map<String, Object> json = new HashMap<String, Object>();
    String message = "Process instance ids is null";
    doThrow(new BadUserRequestException(message)).when(modificationBuilderMock).execute();
    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("processDefinitionId", "processDefinitionId");
    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_SYNC_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 17 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithInvalidProcessInstanceQuerySync.

@Test
public void executeModificationWithInvalidProcessInstanceQuerySync() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    Map<String, Object> json = new HashMap<String, Object>();
    String message = "Process instance ids is null";
    doThrow(new BadUserRequestException(message)).when(modificationBuilderMock).execute();
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.startAfter().activityId("acivityId").getJson());
    ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto();
    processInstanceQueryDto.setBusinessKey("foo");
    json.put("processInstanceQuery", processInstanceQueryDto);
    json.put("instructions", instructions);
    json.put("processDefinitionId", "processDefinitionId");
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(EXECUTE_MODIFICATION_SYNC_URL);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) Matchers.anyString(org.mockito.Matchers.anyString) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 18 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithNullInstructionsAsync.

@Test
public void executeModificationWithNullInstructionsAsync() {
    doThrow(new BadUserRequestException("Instructions must be set")).when(modificationBuilderMock).executeAsync();
    Map<String, Object> json = new HashMap<String, Object>();
    json.put("processInstanceIds", Arrays.asList("200", "11"));
    json.put("skipIoMappings", true);
    json.put("processDefinitionId", "processDefinitionId");
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Instructions must be set")).when().post(EXECUTE_MODIFICATION_ASYNC_URL);
}
Also used : HashMap(java.util.HashMap) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 19 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithNullInstructionsSync.

@Test
public void executeModificationWithNullInstructionsSync() {
    doThrow(new BadUserRequestException("Instructions must be set")).when(modificationBuilderMock).execute();
    Map<String, Object> json = new HashMap<String, Object>();
    json.put("processInstanceIds", Arrays.asList("200", "11"));
    json.put("skipIoMappings", true);
    json.put("processDefinitionId", "processDefinitionId");
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Instructions must be set")).when().post(EXECUTE_MODIFICATION_SYNC_URL);
}
Also used : HashMap(java.util.HashMap) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 20 with BadUserRequestException

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

the class ModificationRestServiceInteractionTest method executeModificationWithNullProcessDefinitionIdAsync.

@Test
public void executeModificationWithNullProcessDefinitionIdAsync() {
    doThrow(new BadUserRequestException("processDefinitionId must be set")).when(modificationBuilderMock).executeAsync();
    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_ASYNC_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).executeAsync();
}
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)

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