HashMap<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("stringVar", "Azerty");
processVariables.put("intVar", 67890);
processVariables.put("booleanVar", false);
Execution parentExecution = runtimeService.startProcessInstanceByKey("processOne", processVariables);
Execution childExecution = runtimeService.createExecutionQuery().activityId("processTask").singleResult();
assertNotNull(childExecution);
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_QUERY);
ObjectNode requestNode = objectMapper.createObjectNode();
ArrayNode variableArray = objectMapper.createArrayNode();
ObjectNode variableNode = objectMapper.createObjectNode();
variableArray.add(variableNode);
requestNode.put("variables", variableArray);
// String equals
variableNode.put("name", "stringVar");
variableNode.put("value", "Azerty");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// Integer equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67890);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// Boolean equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", false);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// String not equals
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "ghijkl");
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// Integer not equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 45678);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// Boolean not equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", true);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// String equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "azeRTY");
variableNode.put("operation", "equalsIgnoreCase");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// String not equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "HIJKLm");
variableNode.put("operation", "notEqualsIgnoreCase");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// String equals without value
variableNode.removeAll();
variableNode.put("value", "Azerty");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, parentExecution.getId());
// Test process-variables on child-execution. Should find both child and process itself
requestNode = objectMapper.createObjectNode();
variableArray = objectMapper.createArrayNode();
variableNode = objectMapper.createObjectNode();
variableArray.add(variableNode);
requestNode.put("processInstanceVariables", variableArray);
// String equals
variableNode.put("name", "stringVar");
variableNode.put("value", "Azerty");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// Integer equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67890);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// Boolean equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", false);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// String not equals
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "ghijkl");
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// Integer not equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 45678);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// Boolean not equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", true);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// String equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "azeRTY");
variableNode.put("operation", "equalsIgnoreCase");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// String not equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "HIJKLm");
variableNode.put("operation", "notEqualsIgnoreCase");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
// String equals without name
variableNode.removeAll();
variableNode.put("value", "Azerty");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, requestNode, childExecution.getId(), parentExecution.getId());
}