Search in sources :

Example 6 with EqualsMap

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)));
}
Also used : EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with EqualsMap

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)));
}
Also used : EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) HashMap(java.util.HashMap) EqualsList(org.camunda.bpm.engine.rest.helper.EqualsList) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with EqualsMap

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();
}
Also used : EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 9 with EqualsMap

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()))));
}
Also used : EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

EqualsMap (org.camunda.bpm.engine.rest.helper.EqualsMap)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 Test (org.junit.Test)9 Matchers.anyString (org.mockito.Matchers.anyString)9 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)3 EqualsList (org.camunda.bpm.engine.rest.helper.EqualsList)3 TaskServiceImpl (org.camunda.bpm.engine.impl.TaskServiceImpl)2 LinkedHashMap (java.util.LinkedHashMap)1