use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testPutSingleBinaryVariableThrowsAuthorizationException.
@Test
public void testPutSingleBinaryVariableThrowsAuthorizationException() {
byte[] bytes = "someContent".getBytes();
String variableKey = "aVariableKey";
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(runtimeServiceMock).setVariable(anyString(), anyString(), any());
given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).pathParam("varId", variableKey).multiPart("data", "unspecified", bytes).expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(SINGLE_PROCESS_INSTANCE_BINARY_VARIABLE_URL);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testPutSingleVariableThrowsAuthorizationException.
@Test
public void testPutSingleVariableThrowsAuthorizationException() {
String variableKey = "aVariableKey";
String variableValue = "1abc";
String type = "String";
Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(runtimeServiceMock).setVariable(anyString(), anyString(), any());
given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).pathParam("varId", variableKey).contentType(ContentType.JSON).body(variableJson).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(SINGLE_PROCESS_INSTANCE_VARIABLE_URL);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testDeleteVariableThrowsAuthorizationException.
@Test
public void testDeleteVariableThrowsAuthorizationException() {
String variableKey = "aVariableKey";
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(runtimeServiceMock).removeVariable(anyString(), anyString());
given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID).pathParam("varId", variableKey).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", is(AuthorizationException.class.getSimpleName())).body("message", is(message)).when().delete(SINGLE_PROCESS_INSTANCE_VARIABLE_URL);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testSuspendProcessInstanceByProcessDefinitionKeyThrowsAuthorizationException.
@Test
public void testSuspendProcessInstanceByProcessDefinitionKeyThrowsAuthorizationException() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("suspended", true);
params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY);
String message = "expectedMessage";
doThrow(new AuthorizationException(message)).when(mockUpdateSuspensionStateBuilder).suspend();
given().contentType(ContentType.JSON).body(params).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(PROCESS_INSTANCE_SUSPENDED_URL);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceInteractionTest method testModifyProcessInstanceThrowsAuthorizationException.
@Test
public void testModifyProcessInstanceThrowsAuthorizationException() {
ProcessInstanceModificationInstantiationBuilder mockModificationBuilder = setUpMockModificationBuilder();
when(runtimeServiceMock.createProcessInstanceModification(anyString())).thenReturn(mockModificationBuilder);
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(mockModificationBuilder).execute(anyBoolean(), anyBoolean());
Map<String, Object> json = new HashMap<String, Object>();
List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
instructions.add(ModificationInstructionBuilder.startBefore().activityId("activityId").variables(VariablesBuilder.create().variable("var", "value", "String", false).variable("varLocal", "valueLocal", "String", true).getVariables()).getJson());
instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").variables(VariablesBuilder.create().variable("var", 52, "Integer", false).variable("varLocal", 74, "Integer", true).getVariables()).getJson());
json.put("instructions", instructions);
given().pathParam("id", EXAMPLE_PROCESS_INSTANCE_ID).contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(PROCESS_INSTANCE_MODIFICATION_URL);
}
Aggregations