Search in sources :

Example 1 with EqualsMap

use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.

the class TaskVariableLocalRestResourceInteractionTest method testLocalVariableModification.

@Test
public void testLocalVariableModification() {
    TaskServiceImpl taskServiceMock = mockTaskServiceImpl();
    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", EXAMPLE_TASK_ID).contentType(ContentType.JSON).body(messageBodyJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(SINGLE_TASK_MODIFY_VARIABLES_URL);
    Map<String, Object> expectedModifications = new HashMap<String, Object>();
    expectedModifications.put(variableKey, variableValue);
    verify(taskServiceMock).updateVariablesLocal(eq(EXAMPLE_TASK_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) TaskServiceImpl(org.camunda.bpm.engine.impl.TaskServiceImpl) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with EqualsMap

use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.

the class MessageRestServiceTest method testFullMessageCorrelation.

@Test
public void testFullMessageCorrelation() {
    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);
    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).correlateWithResult();
// verify(runtimeServiceMock).correlateMessage(eq(messageName), eq(businessKey),
// argThat(new EqualsMap(expectedCorrelationKeys)), argThat(new EqualsMap(expectedVariables)));
}
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 3 with EqualsMap

use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.

the class TaskVariableRestResourceInteractionTest method testVariableModification.

@Test
public void testVariableModification() {
    TaskServiceImpl taskServiceMock = mockTaskServiceImpl();
    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", EXAMPLE_TASK_ID).contentType(ContentType.JSON).body(messageBodyJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(SINGLE_TASK_MODIFY_VARIABLES_URL);
    Map<String, Object> expectedModifications = new HashMap<String, Object>();
    expectedModifications.put(variableKey, variableValue);
    verify(taskServiceMock).updateVariables(eq(EXAMPLE_TASK_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) TaskServiceImpl(org.camunda.bpm.engine.impl.TaskServiceImpl) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with EqualsMap

use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.

the class ExecutionRestServiceInteractionTest method testMessageEventTriggeringWithoutVariables.

@Test
public void testMessageEventTriggeringWithoutVariables() {
    String messageName = "aMessageName";
    given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).pathParam("messageName", messageName).contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(TRIGGER_MESSAGE_SUBSCRIPTION_URL);
    verify(runtimeServiceMock).messageEventReceived(eq(messageName), eq(MockProvider.EXAMPLE_EXECUTION_ID), argThat(new EqualsMap(null)));
}
Also used : EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with EqualsMap

use of org.camunda.bpm.engine.rest.helper.EqualsMap in project camunda-bpm-platform by camunda.

the class ExecutionRestServiceInteractionTest method testSignalExecution.

@Test
public void testSignalExecution() {
    String variableKey = "aKey";
    int variableValue = 123;
    Map<String, Object> variablesJson = new HashMap<String, Object>();
    Map<String, Object> variables = VariablesBuilder.create().variable(variableKey, variableValue).getVariables();
    variablesJson.put("variables", variables);
    given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).contentType(ContentType.JSON).body(variablesJson).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(SIGNAL_EXECUTION_URL);
    Map<String, Object> expectedSignalVariables = new HashMap<String, Object>();
    expectedSignalVariables.put(variableKey, variableValue);
    verify(runtimeServiceMock).signal(eq(MockProvider.EXAMPLE_EXECUTION_ID), argThat(new EqualsMap(expectedSignalVariables)));
}
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)

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