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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations