use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceInteractionTest method testMessageEventTriggering.
@Test
public void testMessageEventTriggering() {
String messageName = "aMessageName";
String variableKey1 = "aVarName";
String variableValue1 = "aVarValue";
String variableKey2 = "anotherVarName";
String variableValue2 = "anotherVarValue";
Map<String, Object> variables = VariablesBuilder.create().variable(variableKey1, variableValue1).variable(variableKey2, variableValue2).getVariables();
Map<String, Object> variablesJson = new HashMap<String, Object>();
variablesJson.put("variables", variables);
given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).pathParam("messageName", messageName).contentType(ContentType.JSON).body(variablesJson).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(TRIGGER_MESSAGE_SUBSCRIPTION_URL);
Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put(variableKey1, variableValue1);
expectedVariables.put(variableKey2, variableValue2);
verify(runtimeServiceMock).messageEventReceived(eq(messageName), eq(MockProvider.EXAMPLE_EXECUTION_ID), argThat(new EqualsMap(expectedVariables)));
}
use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.
the class ExecutionRestServiceInteractionTest method testLocalVariableModification.
@Test
public void testLocalVariableModification() {
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
String variableKey = "aKey";
int variableValue = 123;
Map<String, Object> modifications = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
messageBodyJson.put("modifications", modifications);
List<String> deletions = new ArrayList<String>();
deletions.add("deleteKey");
messageBodyJson.put("deletions", deletions);
given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(EXECUTION_LOCAL_VARIABLES_URL);
Map<String, Object> expectedModifications = new HashMap<String, Object>();
expectedModifications.put(variableKey, variableValue);
verify(runtimeServiceMock).updateVariablesLocal(eq(MockProvider.EXAMPLE_EXECUTION_ID), argThat(new EqualsMap(expectedModifications)), argThat(new EqualsList(deletions)));
}
use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.
the class MessageRestServiceTest method testFullMessageCorrelationAll.
@Test
public void testFullMessageCorrelationAll() {
String messageName = "aMessageName";
String businessKey = "aBusinessKey";
Map<String, Object> variables = VariablesBuilder.create().variable("aKey", "aValue").getVariables();
Map<String, Object> correlationKeys = VariablesBuilder.create().variable("aKey", "aValue").variable("anotherKey", 1).variable("aThirdKey", true).getVariables();
Map<String, Object> localCorrelationKeys = VariablesBuilder.create().variable("aLocalKey", "aValue").variable("anotherLocalKey", 1).variable("aThirdLocalKey", false).getVariables();
Map<String, Object> messageParameters = new HashMap<String, Object>();
messageParameters.put("messageName", messageName);
messageParameters.put("correlationKeys", correlationKeys);
messageParameters.put("localCorrelationKeys", localCorrelationKeys);
messageParameters.put("processVariables", variables);
messageParameters.put("businessKey", businessKey);
messageParameters.put("all", true);
given().contentType(POST_JSON_CONTENT_TYPE).body(messageParameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(MESSAGE_URL);
Map<String, Object> expectedCorrelationKeys = new HashMap<String, Object>();
expectedCorrelationKeys.put("aKey", "aValue");
expectedCorrelationKeys.put("anotherKey", 1);
expectedCorrelationKeys.put("aThirdKey", true);
Map<String, Object> expectedLocalCorrelationKeys = new HashMap<String, Object>();
expectedLocalCorrelationKeys.put("aLocalKey", "aValue");
expectedLocalCorrelationKeys.put("anotherLocalKey", 1);
expectedLocalCorrelationKeys.put("aThirdLocalKey", false);
Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("aKey", "aValue");
verify(runtimeServiceMock).createMessageCorrelation(eq(messageName));
verify(messageCorrelationBuilderMock).processInstanceBusinessKey(eq(businessKey));
verify(messageCorrelationBuilderMock).setVariables(argThat(new EqualsMap(expectedVariables)));
for (Entry<String, Object> expectedKey : expectedCorrelationKeys.entrySet()) {
String name = expectedKey.getKey();
Object value = expectedKey.getValue();
verify(messageCorrelationBuilderMock).processInstanceVariableEquals(name, value);
}
for (Entry<String, Object> expectedLocalKey : expectedLocalCorrelationKeys.entrySet()) {
String name = expectedLocalKey.getKey();
Object value = expectedLocalKey.getValue();
verify(messageCorrelationBuilderMock).localVariableEquals(name, value);
}
verify(messageCorrelationBuilderMock).correlateAllWithResult();
}
use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method testSubmitTaskFormWithBase64EncodedBytes.
@Test
public void testSubmitTaskFormWithBase64EncodedBytes() {
Map<String, Object> variables = VariablesBuilder.create().variable("aVariable", Base64.encodeBase64String("someBytes".getBytes()), "Bytes").getVariables();
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", variables);
given().pathParam("id", EXAMPLE_TASK_ID).header("accept", MediaType.APPLICATION_JSON).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(SUBMIT_FORM_URL);
verify(formServiceMock).submitTaskForm(eq(EXAMPLE_TASK_ID), argThat(new EqualsMap().matcher("aVariable", EqualsPrimitiveValue.bytesValue("someBytes".getBytes()))));
}
Aggregations