List of usage examples for com.fasterxml.jackson.databind.node ObjectNode get
public JsonNode get(String paramString)
From source file:org.apache.streams.rss.serializer.SyndEntryActivitySerializer.java
/** * Given an RSS object, build the ActivityObject * * @param entry/*from w w w.j a v a2s . co m*/ * @return */ private ActivityObject buildActivityObject(ObjectNode entry) { ActivityObject activityObject = new ActivityObject(); JsonNode summary = entry.get("description"); if (summary != null) activityObject.setSummary(summary.textValue()); else if ((summary = entry.get("title")) != null) { activityObject.setSummary(summary.textValue()); } return activityObject; }
From source file:org.activiti.rest.service.api.runtime.ProcessInstanceIdentityLinkResourceTest.java
/** * Test getting all identity links./* w ww .j a v a 2 s . c om*/ */ @Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceIdentityLinkResourceTest.process.bpmn20.xml" }) public void testGetIdentityLinks() throws Exception { // Test candidate user/groups links + manual added identityLink ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.addUserIdentityLink(processInstance.getId(), "john", "customType"); runtimeService.addUserIdentityLink(processInstance.getId(), "paul", "candidate"); // Execute the request CloseableHttpResponse response = executeRequest( new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl( RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINKS_COLLECTION, processInstance.getId())), HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertTrue(responseNode.isArray()); assertEquals(2, responseNode.size()); boolean johnFound = false; boolean paulFound = 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_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "john", "customType"))); johnFound = true; } else { assertEquals("paul", 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_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "paul", "candidate"))); paulFound = true; } } } assertTrue(johnFound); assertTrue(paulFound); }
From source file:org.flowable.rest.service.api.runtime.ProcessInstanceIdentityLinkResourceTest.java
/** * Test getting all identity links./*from w w w. j a v a 2s . c o m*/ */ @Deployment(resources = { "org/flowable/rest/service/api/runtime/ProcessInstanceIdentityLinkResourceTest.process.bpmn20.xml" }) public void testGetIdentityLinks() throws Exception { // Test candidate user/groups links + manual added identityLink ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); runtimeService.addUserIdentityLink(processInstance.getId(), "john", "customType"); runtimeService.addUserIdentityLink(processInstance.getId(), "paul", "candidate"); // Execute the request CloseableHttpResponse response = executeRequest( new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl( RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINKS_COLLECTION, processInstance.getId())), HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertTrue(responseNode.isArray()); assertEquals(2, responseNode.size()); boolean johnFound = false; boolean paulFound = 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_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "john", "customType"))); johnFound = true; } else { assertEquals("paul", 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_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "paul", "candidate"))); paulFound = true; } } } assertTrue(johnFound); assertTrue(paulFound); }
From source file:com.cloud.api.ApiServletTest.java
@SuppressWarnings("unchecked") @Test// ww w. j a va2 s . c o m public void getLoginSuccessResponseJson() throws JsonParseException, IOException { Mockito.when(session.getAttributeNames()) .thenReturn(new IteratorEnumeration(Arrays.asList("foo", "bar", "userid", "domainid").iterator())); Mockito.when(session.getAttribute(Mockito.anyString())).thenReturn("TEST"); String loginResponse = servlet.getLoginSuccessResponse(session, "json"); ObjectNode node = (ObjectNode) new ObjectMapper().readTree(loginResponse); Assert.assertNotNull(node.get("loginresponse")); }
From source file:org.apache.streams.rss.serializer.SyndEntryActivitySerializer.java
/** * Given an RSS entry, extra out the author and actor information and return it * in an actor object/*w ww.j ava2s .c om*/ * * @param entry * @return */ private Actor buildActor(ObjectNode entry) { Author author = new Author(); Actor actor = new Actor(); if (entry.get("author") != null) { author.setId(entry.get("author").textValue()); author.setDisplayName(entry.get("author").textValue()); actor.setAuthor(author); String uriToSet = entry.get("rssFeed") != null ? entry.get("rssFeed").asText() : null; actor.setId("id:rss:" + uriToSet + ":" + author.getId()); actor.setDisplayName(author.getDisplayName()); } return actor; }
From source file:org.jboss.aerogear.simplepush.server.datastore.CouchDBDataStore.java
private Map<String, String> docToAckMap(final ObjectNode doc, final long version) { final String uaid = doc.get(UAID_FIELD).asText(); final String chid = doc.get(CHID_FIELD).asText(); final String token = doc.get(TOKEN_FIELD).asText(); final Map<String, String> map = new HashMap<String, String>(5); map.put(UAID_FIELD, uaid);/*from www. j av a 2 s . c om*/ map.put(TYPE_FIELD, "ack"); map.put(TOKEN_FIELD, token); map.put(CHID_FIELD, chid); map.put(VERSION_FIELD, Long.toString(version)); return map; }
From source file:org.apache.streams.components.http.provider.SimpleHTTPGetProvider.java
@Override public StreamsResultSet readCurrent() { StreamsResultSet current;//w w w . j av a 2s .c om uriBuilder = uriBuilder.setPath(Joiner.on("/").skipNulls().join(uriBuilder.getPath(), configuration.getResource(), configuration.getResourcePostfix())); URI uri; try { uri = uriBuilder.build(); } catch (URISyntaxException e) { uri = null; } List<ObjectNode> results = executeGet(uri); lock.writeLock().lock(); for (ObjectNode item : results) { providerQueue.add( new StreamsDatum(item, item.get("id").asText(), new DateTime(item.get("timestamp").asText()))); } LOGGER.debug("Creating new result set for {} items", providerQueue.size()); current = new StreamsResultSet(providerQueue); return current; }
From source file:io.amient.kafka.metrics.Dashboard.java
public ObjectNode newTarget(ObjectNode panel, String aliasPattern, String rawQuery) { ArrayNode targets = ((ArrayNode) panel.get("targets")); ObjectNode target = targets.addObject(); target.put("refId", Character.toString((char) (64 + targets.size()))); target.put("query", rawQuery); target.put("alias", aliasPattern); target.put("rawQuery", true); return target; }
From source file:com.squarespace.template.ReferenceScannerTest.java
@Test public void testInstructions() throws CodeException { ObjectNode result = scan("{.if a || b}{.newline}{.meta-left}{.space}{.or}{.section a}{.end}{.end}"); render(result);//w ww. j a va 2 s . co m result = scan("{.if even?}a{.or}b{.end}"); render(result); assertEquals(result.get("predicates").get("even?").asInt(), 1); }
From source file:org.apache.taverna.gis.ui.serviceprovider.GisServiceProvider.java
/** * Do the actual search for services. Return using the callBack parameter. *//*from ww w. j a v a 2 s.c om*/ @SuppressWarnings("unchecked") public void findServiceDescriptionsAsync(FindServiceDescriptionsCallBack callBack) { // Use callback.status() for long-running searches callBack.status("Resolving GIS services"); List<ServiceDescription> results = new ArrayList<ServiceDescription>(); // FIXME: Implement the actual service search/lookup instead // of dummy for-loop GisServiceDesc service = new GisServiceDesc(); // Populate the service description bean ObjectNode conf = getConfiguration().getJsonAsObjectNode(); String serviceUri = conf.get("osgiServiceUri").asText(); service.setOgcServiceUri(URI.create(serviceUri)); String processIdentifier = conf.get("processIdentifier").asText(); service.setProcessIdentifier(processIdentifier); // TODO: Optional: set description (Set a better description service.setDescription(processIdentifier); // TODO: Exctract in a separate method // Get input ports WPSClientSession wpsClient = WPSClientSession.getInstance(); ProcessDescriptionType processDescription; try { processDescription = wpsClient.getProcessDescription(serviceUri, processIdentifier); InputDescriptionType[] inputList = processDescription.getDataInputs().getInputArray(); List<ActivityInputPortDefinitionBean> inputPortDefinitions = new ArrayList<ActivityInputPortDefinitionBean>(); for (InputDescriptionType input : inputList) { ActivityInputPortDefinitionBean newInputPort = new ActivityInputPortDefinitionBean(); newInputPort.setName(input.getIdentifier().getStringValue()); newInputPort.setDepth(0); newInputPort.setAllowsLiteralValues(true); newInputPort.setHandledReferenceSchemes(null); newInputPort.setTranslatedElementType(String.class); inputPortDefinitions.add(newInputPort); } // service.setInputPortDefinitions(inputPortDefinitions); // Get output ports OutputDescriptionType[] outputList = processDescription.getProcessOutputs().getOutputArray(); List<ActivityOutputPortDefinitionBean> outputPortDefinitions = new ArrayList<ActivityOutputPortDefinitionBean>(); for (OutputDescriptionType output : outputList) { ActivityOutputPortDefinitionBean newOutputPort = new ActivityOutputPortDefinitionBean(); newOutputPort.setName(output.getIdentifier().getStringValue()); newOutputPort.setDepth(0); outputPortDefinitions.add(newOutputPort); } //service.setOutputPortDefinitions(outputPortDefinitions); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } results.add(service); // partialResults() can also be called several times from inside // for-loop if the full search takes a long time callBack.partialResults(results); // No more results will be coming callBack.finished(); }