Search in sources :

Example 1 with EqualsList

use of org.camunda.bpm.engine.rest.helper.EqualsList 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 EqualsList

use of org.camunda.bpm.engine.rest.helper.EqualsList 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 3 with EqualsList

use of org.camunda.bpm.engine.rest.helper.EqualsList 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 4 with EqualsList

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

the class TaskRestServiceQueryTest method testCandidateGroupInList.

@Test
public void testCandidateGroupInList() {
    List<String> candidateGroups = new ArrayList<String>();
    candidateGroups.add("boss");
    candidateGroups.add("worker");
    String queryParam = candidateGroups.get(0) + "," + candidateGroups.get(1);
    given().queryParams("candidateGroups", queryParam).header("accept", MediaType.APPLICATION_JSON).expect().statusCode(Status.OK.getStatusCode()).when().get(TASK_QUERY_URL);
    verify(mockQuery).taskCandidateGroupIn(argThat(new EqualsList(candidateGroups)));
}
Also used : EqualsList(org.camunda.bpm.engine.rest.helper.EqualsList) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

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