List of usage examples for com.fasterxml.jackson.databind JsonNode size
public int size()
From source file:org.opendaylight.nemo.renderer.openflow.physicalnetwork.PhyConfigLoaderTest.java
@Test public void testBuildLinks() throws Exception { List<PhysicalLink> list; JsonNode hostsNode = mock(JsonNode.class); JsonNode hosts = mock(JsonNode.class); JsonNode jsonNode = mock(JsonNode.class); JsonNode jsonNode1 = mock(JsonNode.class); PhysicalHost physicalHost;/* w ww .ja v a 2 s .com*/ Class<PhyConfigLoader> class1 = PhyConfigLoader.class; Method method = class1.getDeclaredMethod("buildLinks", new Class[] { JsonNode.class }); method.setAccessible(true); when(hostsNode.path(any(String.class))).thenReturn(hosts); when(hosts.size()).thenReturn(1); when(hosts.get(any(Integer.class))).thenReturn(jsonNode); when(jsonNode.get(any(String.class))).thenReturn(jsonNode1).thenReturn(jsonNode1); when(jsonNode1.asText()).thenReturn(new String("test")); when(jsonNode1.asLong()).thenReturn((long) 1); list = (List<PhysicalLink>) method.invoke(phyConfigLoader, hostsNode); Assert.assertTrue(list.size() == 1); }
From source file:com.marklogic.client.test.RawQueryDefinitionTest.java
@Test public void testExtractDocumentData() throws Exception { String options = "<search:options>" + "<search:extract-document-data>" + "<search:extract-path>/root/child</search:extract-path>" + "<search:extract-path>/a/*</search:extract-path>" + "</search:extract-document-data>" + "</search:options>"; // test XML response with extracted XML and JSON matches String combinedSearch = head + qtext4 + options + tail; RawCombinedQueryDefinition rawCombinedQueryDefinition = queryMgr .newRawCombinedQueryDefinition(new StringHandle(combinedSearch).withMimetype("application/xml")); SearchHandle results = queryMgr.search(rawCombinedQueryDefinition, new SearchHandle()); MatchDocumentSummary[] summaries = results.getMatchResults(); assertNotNull(summaries);/*from w ww .j av a 2s . co m*/ assertEquals(2, summaries.length); for (MatchDocumentSummary summary : summaries) { ExtractedResult extracted = summary.getExtracted(); if (Format.XML == summary.getFormat()) { // we don't test for kind because it isn't sent in this case assertEquals(3, extracted.size()); Document item1 = extracted.next().getAs(Document.class); assertEquals("1", item1.getFirstChild().getAttributes().getNamedItem("id").getNodeValue()); Document item2 = extracted.next().getAs(Document.class); assertEquals("2", item2.getFirstChild().getAttributes().getNamedItem("id").getNodeValue()); Document item3 = extracted.next().getAs(Document.class); assertEquals("3", item3.getFirstChild().getAttributes().getNamedItem("id").getNodeValue()); continue; } else if (Format.JSON == summary.getFormat()) { // we don't test for kind because it isn't sent in this case assertEquals(3, extracted.size()); for (ExtractedItem item : extracted) { String stringJsonItem = item.getAs(String.class); JsonNode nodeJsonItem = item.getAs(JsonNode.class); if (nodeJsonItem.has("b1")) { assertEquals("{\"b1\":{\"c\":\"jsonValue1\"}}", stringJsonItem); continue; } else if (nodeJsonItem.has("b2")) { assertTrue(stringJsonItem.matches("\\{\"b2\":\"b2 val[12]\"}")); continue; } fail("unexpected extracted item:" + stringJsonItem); } continue; } fail("unexpected search result:" + summary.getUri()); } // test JSON response with extracted XML and JSON matches JsonNode jsonResults = queryMgr.search(rawCombinedQueryDefinition, new JacksonHandle()).get(); JsonNode jsonSummaries = jsonResults.get("results"); assertNotNull(jsonSummaries); assertEquals(2, jsonSummaries.size()); for (int i = 0; i < jsonSummaries.size(); i++) { JsonNode summary = jsonSummaries.get(i); String format = summary.get("format").textValue(); String docPath = summary.get("path").textValue(); assertNotNull(docPath); JsonNode extracted = summary.get("extracted"); if ("xml".equals(format)) { if (docPath.contains("/sample/first.xml")) { JsonNode extractedItems = extracted.path("content"); assertEquals(3, extractedItems.size()); assertEquals(3, extractedItems.size()); Document item1 = parseXml(extractedItems.get(0).textValue()); assertEquals("1", item1.getFirstChild().getAttributes().getNamedItem("id").getNodeValue()); Document item2 = parseXml(extractedItems.get(1).textValue()); assertEquals("2", item2.getFirstChild().getAttributes().getNamedItem("id").getNodeValue()); Document item3 = parseXml(extractedItems.get(2).textValue()); assertEquals("3", item3.getFirstChild().getAttributes().getNamedItem("id").getNodeValue()); continue; } } else if ("json".equals(format)) { if (docPath.contains("/basic1.json")) { JsonNode items = extracted.get("content"); assertNotNull(items); assertEquals(3, items.size()); assertTrue(items.get(0).has("b1")); assertTrue(items.get(1).has("b2")); assertTrue(items.get(2).has("b2")); continue; } } fail("unexpected search result:" + summary); } // test XML response with full document XML and JSON matches options = "<search:options>" + "<search:extract-document-data selected=\"all\"/>" + "</search:options>"; combinedSearch = head + qtext4 + options + tail; rawCombinedQueryDefinition = queryMgr .newRawCombinedQueryDefinition(new StringHandle(combinedSearch).withMimetype("application/xml")); results = queryMgr.search(rawCombinedQueryDefinition, new SearchHandle()); summaries = results.getMatchResults(); assertNotNull(summaries); assertEquals(2, summaries.length); for (MatchDocumentSummary summary : summaries) { ExtractedResult extracted = summary.getExtracted(); if (Format.XML == summary.getFormat()) { assertEquals("element", extracted.getKind()); assertEquals(1, extracted.size()); Document root = extracted.next().getAs(Document.class); assertEquals("root", root.getFirstChild().getNodeName()); NodeList children = root.getFirstChild().getChildNodes(); assertEquals(3, children.getLength()); Node item1 = children.item(0); assertEquals("1", item1.getAttributes().getNamedItem("id").getNodeValue()); Node item2 = children.item(1); assertEquals("2", item2.getAttributes().getNamedItem("id").getNodeValue()); Node item3 = children.item(2); assertEquals("3", item3.getAttributes().getNamedItem("id").getNodeValue()); continue; } else if (Format.JSON == summary.getFormat()) { assertEquals("object", extracted.getKind()); String jsonDocument = extracted.next().getAs(String.class); assertEquals("{\"a\":{\"b1\":{\"c\":\"jsonValue1\"}, \"b2\":[\"b2 val1\", \"b2 val2\"]}}", jsonDocument); continue; } fail("unexpected search result:" + summary.getUri()); } // test JSON response with full document XML matches jsonResults = queryMgr.search(rawCombinedQueryDefinition, new JacksonHandle()).get(); jsonSummaries = jsonResults.get("results"); assertNotNull(jsonSummaries); assertEquals(2, jsonSummaries.size()); for (int i = 0; i < jsonSummaries.size(); i++) { JsonNode summary = jsonSummaries.get(i); String format = summary.get("format").textValue(); String docPath = summary.get("path").textValue(); assertNotNull(docPath); JsonNode extracted = summary.get("extracted"); if ("xml".equals(format)) { if (docPath.contains("/sample/first.xml")) { assertEquals("fn:doc(\"/sample/first.xml\")", docPath); JsonNode extractedItems = extracted.path("content"); assertEquals(1, extractedItems.size()); Document root = parseXml(extractedItems.get(0).textValue()); assertEquals("root", root.getFirstChild().getNodeName()); NodeList children = root.getFirstChild().getChildNodes(); assertEquals(3, children.getLength()); Node item1 = children.item(0); assertEquals("1", item1.getAttributes().getNamedItem("id").getNodeValue()); Node item2 = children.item(1); assertEquals("2", item2.getAttributes().getNamedItem("id").getNodeValue()); Node item3 = children.item(2); assertEquals("3", item3.getAttributes().getNamedItem("id").getNodeValue()); continue; } } else if ("json".equals(format)) { if (docPath.contains("/basic1.json")) { assertEquals("fn:doc(\"/basic1.json\")", docPath); assertEquals("object", extracted.get("kind").textValue()); JsonNode items = extracted.get("content"); assertNotNull(items); assertEquals(1, items.size()); assertTrue(items.path(0).has("a")); assertTrue(items.path(0).path("a").has("b1")); assertTrue(items.path(0).path("a").path("b1").has("c")); continue; } } fail("unexpected search result:" + summary); } // test XML response with XML and JSON document matches with path that does not match options = "<search:options>" + "<search:extract-document-data>" + "<search:extract-path>/somethingThatShouldNeverMatch</search:extract-path>" + "</search:extract-document-data>" + "</search:options>"; combinedSearch = head + qtext4 + options + tail; rawCombinedQueryDefinition = queryMgr .newRawCombinedQueryDefinition(new StringHandle(combinedSearch).withMimetype("application/xml")); results = queryMgr.search(rawCombinedQueryDefinition, new SearchHandle()); summaries = results.getMatchResults(); assertNotNull(summaries); assertEquals(2, summaries.length); for (MatchDocumentSummary summary : summaries) { ExtractedResult extracted = summary.getExtracted(); assertTrue(extracted.isEmpty()); } // test JSON response with XML and JSON document matches with path that does not match jsonResults = queryMgr.search(rawCombinedQueryDefinition, new JacksonHandle()).get(); jsonSummaries = jsonResults.get("results"); assertNotNull(jsonSummaries); assertEquals(2, jsonSummaries.size()); for (int i = 0; i < jsonSummaries.size(); i++) { JsonNode summary = jsonSummaries.get(i); JsonNode extractedNone = summary.get("extracted-none"); assertNotNull(extractedNone); assertEquals(0, extractedNone.size()); } }
From source file:org.opendaylight.nemo.renderer.cli.physicalnetwork.PhysicalResourceLoader.java
private List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute> buildNodeAttributes( JsonNode attributes) { List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute> attributeList = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute>(); for (int i = 0; i < attributes.size(); i++) { log.debug("build physical port attribute execution body."); JsonNode portAttribute = attributes.get(i); org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.physical.node.instance.Attribute attribute = buildNodeAttribute( portAttribute);/*from w ww . j ava 2s . c om*/ if (attribute != null) { attributeList.add(attribute); } } return attributeList; }
From source file:UploadTest.java
public void loopArray(JsonNode jon) { JsonNode curValue = jon.at("/hasPart"); for (int i = 0; i < curValue.size(); i++) { jon = getFirst(jon.get(i));/* w w w . j a va 2 s .c om*/ System.out.println("Found:" + jon); } }
From source file:org.eel.kitchen.jsonschema.keyword.DependenciesKeywordValidator.java
public DependenciesKeywordValidator(final JsonNode schema) { super("dependencies", NodeType.OBJECT); final Map<String, JsonNode> fields = JacksonUtils.nodeToMap(schema.get("dependencies")); final ImmutableMap.Builder<String, JsonNode> schemaBuilder = new ImmutableMap.Builder<String, JsonNode>(); final ImmutableSetMultimap.Builder<String, String> simpleBuilder = new ImmutableSetMultimap.Builder<String, String>(); String key;/*w w w .j av a 2 s .c om*/ JsonNode value; /* * Walk through the list of fields: * * - if we encounter an object, this is a schema dependency; * - otherwise this is a simple dependency. * * Remember that we went through syntax validation first, * so we are guaranteed about the correctness of the schema. */ for (final Map.Entry<String, JsonNode> entry : fields.entrySet()) { key = entry.getKey(); value = entry.getValue(); if (value.isObject()) { // schema dependency schemaBuilder.put(key, value); continue; } if (value.size() == 0) // single property dependency simpleBuilder.put(key, value.textValue()); else // multiple property dependency for (final JsonNode element : value) simpleBuilder.put(key, element.textValue()); } schemas = schemaBuilder.build(); simple = simpleBuilder.build(); }
From source file:UploadTest.java
private void processObject(JsonNode jon) { getMainObject(jon);//w w w .j av a 2 s.co m jon = jon.at("/hasPart"); for (int i = 0; i < jon.size(); i++) { createObject(getFirst(jon.get(i))); createChildren(getFirst(jon.get(i))); } }
From source file:com.unboundid.scim2.common.DiffTestCase.java
private void removeNullNodes(JsonNode object) { Iterator<JsonNode> i = object.elements(); while (i.hasNext()) { JsonNode field = i.next(); if (field.isNull() || (field.isArray() && field.size() == 0)) { i.remove();//ww w . jav a 2s. c o m } else { removeNullNodes(field); } } }
From source file:org.flowable.rest.service.api.runtime.TaskCollectionResourceTest.java
/** * Test getting a collection of tasks. GET runtime/tasks *//*from w w w. j ava2 s . c o m*/ @Deployment public void testGetTasks() 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.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); runtimeService.setVariable(processInstance.getId(), "variable", "globaltest"); taskService.setVariableLocal(processTask.getId(), "localVariable", "localtest"); // Check filter-less to fetch all tasks String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION); assertResultsPresentInDataResponse(url, adhocTask.getId(), processTask.getId()); // Name filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?name=" + encode("Name one"); assertResultsPresentInDataResponse(url, adhocTask.getId()); // Name like filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?nameLike=" + encode("%one"); assertResultsPresentInDataResponse(url, adhocTask.getId()); // Description filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?description=" + encode("Description one"); assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?description=" + encode("Description two"); assertEmptyResultsPresentInDataResponse(url); // Description like filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?descriptionLike=" + encode("%one"); assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?descriptionLike=" + encode("%two"); assertEmptyResultsPresentInDataResponse(url); // Priority filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?priority=100"; assertResultsPresentInDataResponse(url, adhocTask.getId()); // Mininmum Priority filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?minimumPriority=70"; assertResultsPresentInDataResponse(url, adhocTask.getId()); // Maximum Priority filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?maximumPriority=70"; assertResultsPresentInDataResponse(url, processTask.getId()); // Owner filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?owner=owner"; assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?owner=kermit"; assertEmptyResultsPresentInDataResponse(url); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?ownerLike=" + encode("%ner"); assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?ownerLike=" + encode("kerm%"); assertEmptyResultsPresentInDataResponse(url); // Assignee filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assignee=gonzo"; assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assignee=kermit"; assertEmptyResultsPresentInDataResponse(url); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assigneeLike=" + encode("gon%"); assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assigneeLike=" + encode("kerm%"); assertEmptyResultsPresentInDataResponse(url); // Unassigned filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?unassigned=true"; assertResultsPresentInDataResponse(url, processTask.getId()); // Delegation state filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?delegationState=pending"; assertResultsPresentInDataResponse(url, adhocTask.getId()); // Candidate user filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?candidateUser=kermit"; assertResultsPresentInDataResponse(url, processTask.getId()); // Candidate group filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?candidateGroup=sales"; assertResultsPresentInDataResponse(url, processTask.getId()); // Involved user filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?involvedUser=misspiggy"; assertResultsPresentInDataResponse(url, adhocTask.getId()); // Process instance filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processInstanceId=" + processInstance.getId(); assertResultsPresentInDataResponse(url, processTask.getId()); // Execution filtering Execution taskExecution = runtimeService.createExecutionQuery().activityId("processTask") .singleResult(); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?executionId=" + taskExecution.getId(); assertResultsPresentInDataResponse(url, processTask.getId()); // Process instance businesskey filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processInstanceBusinessKey=myBusinessKey"; assertResultsPresentInDataResponse(url, processTask.getId()); // CreatedOn filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?createdOn=" + getISODateString(adhocTaskCreate.getTime()); assertResultsPresentInDataResponse(url, adhocTask.getId()); // CreatedAfter filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?createdAfter=" + getISODateString(inBetweenTaskCreation.getTime()); assertResultsPresentInDataResponse(url, processTask.getId()); // CreatedBefore filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?createdBefore=" + getISODateString(inBetweenTaskCreation.getTime()); assertResultsPresentInDataResponse(url, adhocTask.getId()); // Subtask exclusion url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?excludeSubTasks=true"; assertResultsPresentInDataResponse(url, adhocTask.getId()); // Task definition key filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?taskDefinitionKey=processTask"; assertResultsPresentInDataResponse(url, processTask.getId()); // Task definition key like filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?taskDefinitionKeyLike=" + encode("process%"); assertResultsPresentInDataResponse(url, processTask.getId()); // Duedate filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?dueDate=" + getISODateString(adhocTaskCreate.getTime()); assertResultsPresentInDataResponse(url, adhocTask.getId()); // Due after filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?dueAfter=" + getISODateString(inBetweenTaskCreation.getTime()); assertResultsPresentInDataResponse(url, processTask.getId()); // Due before filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?dueBefore=" + getISODateString(inBetweenTaskCreation.getTime()); assertResultsPresentInDataResponse(url, adhocTask.getId()); // Without tenantId filtering before tenant set url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?withoutTenantId=true"; assertResultsPresentInDataResponse(url, adhocTask.getId(), processTask.getId()); // Process definition url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processDefinitionKey=" + processInstance.getProcessDefinitionKey(); assertResultsPresentInDataResponse(url, processTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processDefinitionId=" + processInstance.getProcessDefinitionId(); assertResultsPresentInDataResponse(url, processTask.getId()); // Set tenant on deployment managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant")); // Without tenantId filtering after tenant set, only adhoc task // should remain url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?withoutTenantId=true"; assertResultsPresentInDataResponse(url, adhocTask.getId()); // Tenant id filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?tenantId=myTenant"; assertResultsPresentInDataResponse(url, processTask.getId()); // Tenant id like filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?tenantIdLike=" + encode("%enant"); assertResultsPresentInDataResponse(url, processTask.getId()); // Category filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?category=" + encode("some-category"); assertResultsPresentInDataResponse(url, adhocTask.getId()); // Suspend process-instance to have a suspended task runtimeService.suspendProcessInstanceById(processInstance.getId()); // Suspended filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?active=false"; assertResultsPresentInDataResponse(url, processTask.getId()); // Active filtering url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?active=true"; assertResultsPresentInDataResponse(url, adhocTask.getId()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?includeTaskLocalVariables=true"; CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + url), HttpStatus.SC_OK); // Check status and size JsonNode dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data"); closeResponse(response); Assert.assertEquals(2, dataNode.size()); Map<String, JsonNode> taskNodeMap = new HashMap<>(); for (JsonNode taskNode : dataNode) { taskNodeMap.put(taskNode.get("id").asText(), taskNode); } Assert.assertTrue(taskNodeMap.containsKey(processTask.getId())); JsonNode processTaskNode = taskNodeMap.get(processTask.getId()); JsonNode variablesNode = processTaskNode.get("variables"); assertEquals(1, variablesNode.size()); JsonNode variableNode = variablesNode.get(0); assertEquals("localVariable", variableNode.get("name").asText()); assertEquals("local", variableNode.get("scope").asText()); assertEquals("localtest", variableNode.get("value").asText()); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?includeTaskLocalVariables=true&includeProcessVariables=true"; response = executeRequest(new HttpGet(SERVER_URL_PREFIX + url), HttpStatus.SC_OK); // Check status and size dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data"); closeResponse(response); Assert.assertEquals(2, dataNode.size()); taskNodeMap = new HashMap<>(); for (JsonNode taskNode : dataNode) { taskNodeMap.put(taskNode.get("id").asText(), taskNode); } Assert.assertTrue(taskNodeMap.containsKey(processTask.getId())); processTaskNode = taskNodeMap.get(processTask.getId()); variablesNode = processTaskNode.get("variables"); assertEquals(2, variablesNode.size()); Map<String, JsonNode> variableMap = new HashMap<>(); for (JsonNode variableResponseNode : variablesNode) { variableMap.put(variableResponseNode.get("name").asText(), variableResponseNode); } variableNode = variableMap.get("localVariable"); assertEquals("localVariable", variableNode.get("name").asText()); assertEquals("local", variableNode.get("scope").asText()); assertEquals("localtest", variableNode.get("value").asText()); variableNode = variableMap.get("variable"); assertEquals("variable", variableNode.get("name").asText()); assertEquals("global", variableNode.get("scope").asText()); assertEquals("globaltest", variableNode.get("value").asText()); } 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); } } } }