use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class BpmnJsonConverter method convertToJson.
public ObjectNode convertToJson(BpmnModel model) {
ObjectNode modelNode = objectMapper.createObjectNode();
double maxX = 0.0;
double maxY = 0.0;
for (GraphicInfo flowInfo : model.getLocationMap().values()) {
if ((flowInfo.getX() + flowInfo.getWidth()) > maxX) {
maxX = flowInfo.getX() + flowInfo.getWidth();
}
if ((flowInfo.getY() + flowInfo.getHeight()) > maxY) {
maxY = flowInfo.getY() + flowInfo.getHeight();
}
}
maxX += 50;
maxY += 50;
if (maxX < 1485) {
maxX = 1485;
}
if (maxY < 700) {
maxY = 700;
}
modelNode.put("bounds", BpmnJsonConverterUtil.createBoundsNode(maxX, maxY, 0, 0));
modelNode.put("resourceId", "canvas");
ObjectNode stencilNode = objectMapper.createObjectNode();
stencilNode.put("id", "BPMNDiagram");
modelNode.put("stencil", stencilNode);
ObjectNode stencilsetNode = objectMapper.createObjectNode();
stencilsetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
stencilsetNode.put("url", "../editor/stencilsets/bpmn2.0/bpmn2.0.json");
modelNode.put("stencilset", stencilsetNode);
ArrayNode shapesArrayNode = objectMapper.createArrayNode();
Process mainProcess = null;
if (model.getPools().size() > 0) {
mainProcess = model.getProcess(model.getPools().get(0).getId());
} else {
mainProcess = model.getMainProcess();
}
ObjectNode propertiesNode = objectMapper.createObjectNode();
if (StringUtils.isNotEmpty(mainProcess.getId())) {
propertiesNode.put(PROPERTY_PROCESS_ID, mainProcess.getId());
}
if (StringUtils.isNotEmpty(mainProcess.getName())) {
propertiesNode.put(PROPERTY_NAME, mainProcess.getName());
}
if (StringUtils.isNotEmpty(mainProcess.getDocumentation())) {
propertiesNode.put(PROPERTY_DOCUMENTATION, mainProcess.getDocumentation());
}
if (mainProcess.isExecutable() == false) {
propertiesNode.put(PROPERTY_PROCESS_EXECUTABLE, "No");
}
if (StringUtils.isNoneEmpty(model.getTargetNamespace())) {
propertiesNode.put(PROPERTY_PROCESS_NAMESPACE, model.getTargetNamespace());
}
BpmnJsonConverterUtil.convertMessagesToJson(model.getMessages(), propertiesNode);
BpmnJsonConverterUtil.convertListenersToJson(mainProcess.getExecutionListeners(), true, propertiesNode);
BpmnJsonConverterUtil.convertEventListenersToJson(mainProcess.getEventListeners(), propertiesNode);
BpmnJsonConverterUtil.convertSignalDefinitionsToJson(model, propertiesNode);
BpmnJsonConverterUtil.convertMessagesToJson(model, propertiesNode);
if (CollectionUtils.isNotEmpty(mainProcess.getDataObjects())) {
BpmnJsonConverterUtil.convertDataPropertiesToJson(mainProcess.getDataObjects(), propertiesNode);
}
modelNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
boolean poolHasDI = false;
if (model.getPools().size() > 0) {
for (Pool pool : model.getPools()) {
GraphicInfo graphicInfo = model.getGraphicInfo(pool.getId());
if (graphicInfo != null) {
poolHasDI = true;
break;
}
}
}
if (model.getPools().size() > 0 && poolHasDI) {
for (Pool pool : model.getPools()) {
GraphicInfo graphicInfo = model.getGraphicInfo(pool.getId());
if (graphicInfo == null)
continue;
ObjectNode poolNode = BpmnJsonConverterUtil.createChildShape(pool.getId(), STENCIL_POOL, graphicInfo.getX() + graphicInfo.getWidth(), graphicInfo.getY() + graphicInfo.getHeight(), graphicInfo.getX(), graphicInfo.getY());
shapesArrayNode.add(poolNode);
ObjectNode poolPropertiesNode = objectMapper.createObjectNode();
poolPropertiesNode.put(PROPERTY_OVERRIDE_ID, pool.getId());
poolPropertiesNode.put(PROPERTY_PROCESS_ID, pool.getProcessRef());
if (pool.isExecutable() == false) {
poolPropertiesNode.put(PROPERTY_PROCESS_EXECUTABLE, PROPERTY_VALUE_NO);
}
if (StringUtils.isNotEmpty(pool.getName())) {
poolPropertiesNode.put(PROPERTY_NAME, pool.getName());
}
poolNode.put(EDITOR_SHAPE_PROPERTIES, poolPropertiesNode);
ArrayNode laneShapesArrayNode = objectMapper.createArrayNode();
poolNode.put(EDITOR_CHILD_SHAPES, laneShapesArrayNode);
ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
poolNode.put("outgoing", outgoingArrayNode);
Process process = model.getProcess(pool.getId());
if (process != null) {
Map<String, ArrayNode> laneMap = new HashMap<String, ArrayNode>();
for (Lane lane : process.getLanes()) {
GraphicInfo laneGraphicInfo = model.getGraphicInfo(lane.getId());
if (laneGraphicInfo == null)
continue;
ObjectNode laneNode = BpmnJsonConverterUtil.createChildShape(lane.getId(), STENCIL_LANE, laneGraphicInfo.getX() + laneGraphicInfo.getWidth(), laneGraphicInfo.getY() + laneGraphicInfo.getHeight(), laneGraphicInfo.getX(), laneGraphicInfo.getY());
laneShapesArrayNode.add(laneNode);
ObjectNode lanePropertiesNode = objectMapper.createObjectNode();
lanePropertiesNode.put(PROPERTY_OVERRIDE_ID, lane.getId());
if (StringUtils.isNotEmpty(lane.getName())) {
lanePropertiesNode.put(PROPERTY_NAME, lane.getName());
}
laneNode.put(EDITOR_SHAPE_PROPERTIES, lanePropertiesNode);
ArrayNode elementShapesArrayNode = objectMapper.createArrayNode();
laneNode.put(EDITOR_CHILD_SHAPES, elementShapesArrayNode);
laneNode.put("outgoing", objectMapper.createArrayNode());
laneMap.put(lane.getId(), elementShapesArrayNode);
}
for (FlowElement flowElement : process.getFlowElements()) {
Lane laneForElement = null;
GraphicInfo laneGraphicInfo = null;
FlowElement lookForElement = null;
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
lookForElement = model.getFlowElement(sequenceFlow.getSourceRef());
} else {
lookForElement = flowElement;
}
for (Lane lane : process.getLanes()) {
if (lane.getFlowReferences().contains(lookForElement.getId())) {
laneGraphicInfo = model.getGraphicInfo(lane.getId());
if (laneGraphicInfo != null) {
laneForElement = lane;
}
break;
}
}
if (flowElement instanceof SequenceFlow || laneForElement != null) {
processFlowElement(flowElement, process, model, laneMap.get(laneForElement.getId()), laneGraphicInfo.getX(), laneGraphicInfo.getY());
}
}
processArtifacts(process, model, shapesArrayNode, 0.0, 0.0);
}
for (MessageFlow messageFlow : model.getMessageFlows().values()) {
if (messageFlow.getSourceRef().equals(pool.getId())) {
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId()));
}
}
}
processMessageFlows(model, shapesArrayNode);
} else {
processFlowElements(model.getMainProcess(), model, shapesArrayNode, 0.0, 0.0);
processMessageFlows(model, shapesArrayNode);
}
modelNode.put(EDITOR_CHILD_SHAPES, shapesArrayNode);
return modelNode;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class TaskIdentityLinkResourceTest method testGetIdentityLinks.
/**
* Test getting all identity links.
* GET runtime/tasks/{taskId}/identitylinks
*/
@Deployment
public void testGetIdentityLinks() throws Exception {
// Test candidate user/groups links + manual added identityLink
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("identityLinkProcess");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.addUserIdentityLink(task.getId(), "john", "customType");
assertEquals(3, taskService.getIdentityLinksForTask(task.getId()).size());
// Execute the request
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_IDENTITYLINKS_COLLECTION, task.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(3, responseNode.size());
boolean groupCandidateFound = false;
boolean userCandidateFound = false;
boolean customLinkFound = false;
for (int i = 0; i < responseNode.size(); i++) {
ObjectNode link = (ObjectNode) responseNode.get(i);
assertNotNull(link);
if (!link.get("user").isNull()) {
if (link.get("user").textValue().equals("john")) {
assertEquals("customType", link.get("type").textValue());
assertTrue(link.get("group").isNull());
assertTrue(link.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_IDENTITYLINK, task.getId(), "users", "john", "customType")));
customLinkFound = true;
} else {
assertEquals("kermit", link.get("user").textValue());
assertEquals("candidate", link.get("type").textValue());
assertTrue(link.get("group").isNull());
assertTrue(link.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_IDENTITYLINK, task.getId(), "users", "kermit", "candidate")));
userCandidateFound = true;
}
} else if (!link.get("group").isNull()) {
assertEquals("sales", link.get("group").textValue());
assertEquals("candidate", link.get("type").textValue());
assertTrue(link.get("user").isNull());
assertTrue(link.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_IDENTITYLINK, task.getId(), RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS, "sales", "candidate")));
groupCandidateFound = true;
}
}
assertTrue(groupCandidateFound);
assertTrue(userCandidateFound);
assertTrue(customLinkFound);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class TaskQueryResourceTest method testQueryTasks.
/**
* Test querying tasks.
* GET runtime/tasks
*/
@Deployment
public void testQueryTasks() throws Exception {
try {
Calendar adhocTaskCreate = Calendar.getInstance();
adhocTaskCreate.set(Calendar.MILLISECOND, 0);
Calendar processTaskCreate = Calendar.getInstance();
processTaskCreate.add(Calendar.HOUR, 2);
processTaskCreate.set(Calendar.MILLISECOND, 0);
Calendar inBetweenTaskCreation = Calendar.getInstance();
inBetweenTaskCreation.add(Calendar.HOUR, 1);
processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
Task adhocTask = taskService.newTask();
adhocTask.setAssignee("gonzo");
adhocTask.setOwner("owner");
adhocTask.setDelegationState(DelegationState.PENDING);
adhocTask.setDescription("Description one");
adhocTask.setName("Name one");
adhocTask.setDueDate(adhocTaskCreate.getTime());
adhocTask.setPriority(100);
adhocTask.setFormKey("myForm.json");
adhocTask.setCategory("some-category");
taskService.saveTask(adhocTask);
taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT);
processEngineConfiguration.getClock().setCurrentTime(processTaskCreate.getTime());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey");
Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
processTask.setParentTaskId(adhocTask.getId());
processTask.setPriority(50);
processTask.setDueDate(processTaskCreate.getTime());
taskService.saveTask(processTask);
// Check filter-less to fetch all tasks
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY);
ObjectNode requestNode = objectMapper.createObjectNode();
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId(), adhocTask.getId());
// Name filtering
requestNode.removeAll();
requestNode.put("name", "Name one");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Name like filtering
requestNode.removeAll();
requestNode.put("nameLike", "%one");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Description filtering
requestNode.removeAll();
requestNode.put("description", "Description one");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Description like filtering
requestNode.removeAll();
requestNode.put("descriptionLike", "%one");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Priority filtering
requestNode.removeAll();
requestNode.put("priority", 100);
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Mininmum Priority filtering
requestNode.removeAll();
requestNode.put("minimumPriority", 70);
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Maximum Priority filtering
requestNode.removeAll();
requestNode.put("maximumPriority", 70);
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Owner filtering
requestNode.removeAll();
requestNode.put("owner", "owner");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Assignee filtering
requestNode.removeAll();
requestNode.put("assignee", "gonzo");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Owner like filtering
requestNode.removeAll();
requestNode.put("ownerLike", "owne%");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Assignee like filtering
requestNode.removeAll();
requestNode.put("assigneeLike", "%onzo");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Unassigned filtering
requestNode.removeAll();
requestNode.put("unassigned", true);
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Delegation state filtering
requestNode.removeAll();
requestNode.put("delegationState", "pending");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Candidate user filtering
requestNode.removeAll();
requestNode.put("candidateUser", "kermit");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Candidate group filtering
requestNode.removeAll();
requestNode.put("candidateGroup", "sales");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Candidate group In filtering
requestNode.removeAll();
ArrayNode arrayNode = requestNode.arrayNode();
arrayNode.add("sales");
arrayNode.add("someOtherGroup");
requestNode.put("candidateGroupIn", arrayNode);
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Involved user filtering
requestNode.removeAll();
requestNode.put("involvedUser", "misspiggy");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Process instance filtering
requestNode.removeAll();
requestNode.put("processInstanceId", processInstance.getId());
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process instance id in filtering
requestNode.removeAll();
arrayNode = requestNode.arrayNode();
arrayNode.add(processInstance.getId());
requestNode.put("processInstanceIdIn", arrayNode);
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Execution filtering
requestNode.removeAll();
requestNode.put("executionId", processInstance.getId());
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process instance businesskey filtering
requestNode.removeAll();
requestNode.put("processInstanceBusinessKey", "myBusinessKey");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process instance businesskey like filtering
requestNode.removeAll();
requestNode.put("processInstanceBusinessKeyLike", "myBusiness%");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process definition key
requestNode.removeAll();
requestNode.put("processDefinitionKey", "oneTaskProcess");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process definition key like
requestNode.removeAll();
requestNode.put("processDefinitionKeyLike", "%TaskProcess");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process definition name
requestNode.removeAll();
requestNode.put("processDefinitionName", "The One Task Process");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Process definition name like
requestNode.removeAll();
requestNode.put("processDefinitionNameLike", "The One %");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// CeatedOn filtering
requestNode.removeAll();
requestNode.put("createdOn", getISODateString(adhocTaskCreate.getTime()));
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// CreatedAfter filtering
requestNode.removeAll();
requestNode.put("createdAfter", getISODateString(inBetweenTaskCreation.getTime()));
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// CreatedBefore filtering
requestNode.removeAll();
requestNode.put("createdBefore", getISODateString(inBetweenTaskCreation.getTime()));
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Subtask exclusion
requestNode.removeAll();
requestNode.put("excludeSubTasks", true);
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Task definition key filtering
requestNode.removeAll();
requestNode.put("taskDefinitionKey", "processTask");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Task definition key like filtering
requestNode.removeAll();
requestNode.put("taskDefinitionKeyLike", "process%");
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Duedate filtering
requestNode.removeAll();
requestNode.put("dueDate", getISODateString(adhocTaskCreate.getTime()));
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Due after filtering
requestNode.removeAll();
requestNode.put("dueAfter", getISODateString(inBetweenTaskCreation.getTime()));
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Due before filtering
requestNode.removeAll();
requestNode.put("dueBefore", getISODateString(inBetweenTaskCreation.getTime()));
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Suspend process-instance to have a supended task
runtimeService.suspendProcessInstanceById(processInstance.getId());
// Suspended filering
requestNode.removeAll();
requestNode.put("active", false);
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
// Active filtering
requestNode.removeAll();
requestNode.put("active", true);
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Filtering by category
requestNode.removeAll();
requestNode.put("category", "some-category");
assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId());
// Filtering without duedate
requestNode.removeAll();
requestNode.put("withoutDueDate", true);
// No response should be returned, no tasks without a duedate yet
assertResultsPresentInPostDataResponse(url, requestNode);
processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
processTask.setDueDate(null);
taskService.saveTask(processTask);
assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId());
} finally {
// Clean adhoc-tasks even if test fails
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
if (task.getExecutionId() == null) {
taskService.deleteTask(task.getId(), true);
}
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class TaskQueryResourceTest method testQueryTasksWithVariables.
/**
* Test querying tasks using task and process variables. GET runtime/tasks
*/
@Deployment
public void testQueryTasksWithVariables() throws Exception {
HashMap<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("stringVar", "Azerty");
processVariables.put("intVar", 67890);
processVariables.put("booleanVar", false);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", processVariables);
Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("stringVar", "Abcdef");
variables.put("intVar", 12345);
variables.put("booleanVar", true);
taskService.setVariablesLocal(processTask.getId(), variables);
// Additional tasks to confirm it's filtered out
runtimeService.startProcessInstanceByKey("oneTaskProcess");
ObjectNode taskVariableRequestNode = objectMapper.createObjectNode();
ArrayNode variableArray = objectMapper.createArrayNode();
ObjectNode variableNode = objectMapper.createObjectNode();
variableArray.add(variableNode);
taskVariableRequestNode.put("taskVariables", variableArray);
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY);
// String equals
variableNode.put("name", "stringVar");
variableNode.put("value", "Abcdef");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Integer equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 12345);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Boolean equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", true);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// String not equals
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "ghijkl");
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Integer not equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 45678);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Boolean not equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", false);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// String equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "abCDEF");
variableNode.put("operation", "equalsIgnoreCase");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// String not equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "HIJKLm");
variableNode.put("operation", "notEqualsIgnoreCase");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// String equals without value
variableNode.removeAll();
variableNode.put("value", "Abcdef");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Greater than
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 12300);
variableNode.put("operation", "greaterThan");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
variableNode.put("value", 12345);
variableNode.put("operation", "greaterThan");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode);
// Greater than or equal
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 12300);
variableNode.put("operation", "greaterThanOrEquals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
variableNode.put("value", 12345);
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Less than
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 12400);
variableNode.put("operation", "lessThan");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
variableNode.put("value", 12345);
variableNode.put("operation", "lessThan");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode);
// Less than or equal
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 12400);
variableNode.put("operation", "lessThanOrEquals");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
variableNode.put("value", 12345);
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// Like
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "Abcde%");
variableNode.put("operation", "like");
// Any other operation but equals without value
variableNode.removeAll();
variableNode.put("value", "abcdef");
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponseWithStatusCheck(url, taskVariableRequestNode, HttpStatus.SC_BAD_REQUEST);
// Illegal (but existing) operation
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "abcdef");
variableNode.put("operation", "operationX");
assertResultsPresentInPostDataResponseWithStatusCheck(url, taskVariableRequestNode, HttpStatus.SC_BAD_REQUEST);
// String like case does not match
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "%Abc%");
variableNode.put("operation", "like");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// String like case does not match
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "%Bcde%");
variableNode.put("operation", "like");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode);
// String like ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "%Bcde%");
variableNode.put("operation", "likeIgnoreCase");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode, processTask.getId());
// String like ignore case process not found
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "%xyz%");
variableNode.put("operation", "likeIgnoreCase");
assertResultsPresentInPostDataResponse(url, taskVariableRequestNode);
// Process variables
ObjectNode processVariableRequestNode = objectMapper.createObjectNode();
variableArray = objectMapper.createArrayNode();
variableNode = objectMapper.createObjectNode();
variableArray.add(variableNode);
processVariableRequestNode.put("processInstanceVariables", variableArray);
// String equals
variableNode.put("name", "stringVar");
variableNode.put("value", "Azerty");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Integer equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67890);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Boolean equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", false);
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// String not equals
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "ghijkl");
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Integer not equals
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 45678);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Boolean not equals
variableNode.removeAll();
variableNode.put("name", "booleanVar");
variableNode.put("value", true);
variableNode.put("operation", "notEquals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// String equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "azeRTY");
variableNode.put("operation", "equalsIgnoreCase");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// String not equals ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "HIJKLm");
variableNode.put("operation", "notEqualsIgnoreCase");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// String equals without value
variableNode.removeAll();
variableNode.put("value", "Azerty");
variableNode.put("operation", "equals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Greater than
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67800);
variableNode.put("operation", "greaterThan");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
variableNode.put("value", 67890);
variableNode.put("operation", "greaterThan");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode);
// Greater than or equal
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67800);
variableNode.put("operation", "greaterThanOrEquals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
variableNode.put("value", 67890);
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Less than
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67900);
variableNode.put("operation", "lessThan");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
variableNode.put("value", 67890);
variableNode.put("operation", "lessThan");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode);
// Less than or equal
variableNode.removeAll();
variableNode.put("name", "intVar");
variableNode.put("value", 67900);
variableNode.put("operation", "lessThanOrEquals");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
variableNode.put("value", 67890);
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Like
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "Azert%");
variableNode.put("operation", "like");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// incomplete Like missing wildcard does not match
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "Azert");
variableNode.put("operation", "like");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode);
// complete Like missing wildcard does match
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "Azerty");
variableNode.put("operation", "like");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
// Like ignore case
variableNode.removeAll();
variableNode.put("name", "stringVar");
variableNode.put("value", "%aZeRt%");
variableNode.put("operation", "likeIgnoreCase");
assertResultsPresentInPostDataResponse(url, processVariableRequestNode, processTask.getId());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.
the class TaskQueryResourceTest method testQueryTasksWithPaging.
/**
* Test querying tasks.
* GET runtime/tasks
*/
public void testQueryTasksWithPaging() throws Exception {
try {
Calendar adhocTaskCreate = Calendar.getInstance();
adhocTaskCreate.set(Calendar.MILLISECOND, 0);
processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
List<String> taskIdList = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
Task adhocTask = taskService.newTask();
adhocTask.setAssignee("gonzo");
adhocTask.setOwner("owner");
adhocTask.setDelegationState(DelegationState.PENDING);
adhocTask.setDescription("Description one");
adhocTask.setName("Name one");
adhocTask.setDueDate(adhocTaskCreate.getTime());
adhocTask.setPriority(100);
taskService.saveTask(adhocTask);
taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT);
taskIdList.add(adhocTask.getId());
}
Collections.sort(taskIdList);
// Check filter-less to fetch all tasks
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY);
ObjectNode requestNode = objectMapper.createObjectNode();
String[] taskIds = new String[] { taskIdList.get(0), taskIdList.get(1), taskIdList.get(2) };
assertResultsPresentInPostDataResponse(url + "?size=3&sort=id&order=asc", requestNode, taskIds);
taskIds = new String[] { taskIdList.get(4), taskIdList.get(5), taskIdList.get(6), taskIdList.get(7) };
assertResultsPresentInPostDataResponse(url + "?start=4&size=4&sort=id&order=asc", requestNode, taskIds);
taskIds = new String[] { taskIdList.get(8), taskIdList.get(9) };
assertResultsPresentInPostDataResponse(url + "?start=8&size=10&sort=id&order=asc", requestNode, taskIds);
} finally {
// Clean adhoc-tasks even if test fails
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
if (task.getExecutionId() == null) {
taskService.deleteTask(task.getId(), true);
}
}
}
}
Aggregations