use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project graphhopper by graphhopper.
the class GHMatrixBatchRequester method createPointList.
protected final ArrayNode createPointList(List<GHPoint> list) {
// new ArrayList<>(list.size())
ArrayNode outList = factory.arrayNode(list.size());
for (GHPoint p : list) {
ArrayNode entry = factory.arrayNode(2);
entry.add(p.lon);
entry.add(p.lat);
outList.add(entry);
}
return outList;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project graphhopper by graphhopper.
the class NearestServletIT method testBasicNearestQuery.
@Test
public void testBasicNearestQuery() throws Exception {
JsonNode json = nearestQuery("point=42.554851,1.536198");
assertFalse(json.has("error"));
ArrayNode point = (ArrayNode) json.get("coordinates");
assertTrue("returned point is not 2D: " + point, point.size() == 2);
double lon = point.get(0).asDouble();
double lat = point.get(1).asDouble();
assertTrue("nearest point wasn't correct: lat=" + lat + ", lon=" + lon, lat == 42.55483907636756 && lon == 1.5363742288086868);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project graphhopper by graphhopper.
the class NearestServletWithEleIT method testWithEleQuery.
@Test
public void testWithEleQuery() throws Exception {
JsonNode json = nearestQuery("point=43.730864,7.420771&elevation=true");
assertFalse(json.has("error"));
ArrayNode point = (ArrayNode) json.get("coordinates");
assertTrue("returned point is not 3D: " + point, point.size() == 3);
double lon = point.get(0).asDouble();
double lat = point.get(1).asDouble();
double ele = point.get(2).asDouble();
assertTrue("nearest point wasn't correct: lat=" + lat + ", lon=" + lon + ", ele=" + ele, lat == 43.73070006215647 && lon == 7.421392181993846 && ele == 66.0);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project cas by apereo.
the class OAuth20ProfileControllerTests method verifyOKWithExpiredTicketGrantingTicket.
@Test
public void verifyOKWithExpiredTicketGrantingTicket() throws Exception {
final Map<String, Object> map = new HashMap<>();
map.put(NAME, VALUE);
final List<String> list = Arrays.asList(VALUE, VALUE);
map.put(NAME2, list);
final Principal principal = CoreAuthenticationTestUtils.getPrincipal(ID, map);
final Authentication authentication = getAuthentication(principal);
final AccessToken accessToken = accessTokenFactory.create(RegisteredServiceTestUtils.getService(), authentication, new MockTicketGrantingTicket("casuser"), new ArrayList<>());
accessToken.getTicketGrantingTicket().markTicketExpired();
this.ticketRegistry.addTicket(accessToken);
final MockHttpServletRequest mockRequest = new MockHttpServletRequest(GET, CONTEXT + OAuth20Constants.PROFILE_URL);
mockRequest.setParameter(OAuth20Constants.ACCESS_TOKEN, accessToken.getId());
final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
final ResponseEntity<String> entity = oAuth20ProfileController.handleRequest(mockRequest, mockResponse);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals(CONTENT_TYPE, mockResponse.getContentType());
final ObjectNode expectedObj = MAPPER.createObjectNode();
final ObjectNode attrNode = MAPPER.createObjectNode();
attrNode.put(NAME, VALUE);
final ArrayNode values = MAPPER.createArrayNode();
values.add(VALUE);
values.add(VALUE);
attrNode.put(NAME2, values);
expectedObj.put("id", ID);
expectedObj.put("attributes", attrNode);
final JsonNode receivedObj = MAPPER.readTree(entity.getBody());
assertEquals(expectedObj.get("id").asText(), receivedObj.get("id").asText());
final JsonNode expectedAttributes = expectedObj.get(ATTRIBUTES_PARAM);
final JsonNode receivedAttributes = receivedObj.get(ATTRIBUTES_PARAM);
assertEquals(expectedAttributes.findValue(NAME).asText(), receivedAttributes.findValue(NAME).asText());
assertEquals(expectedAttributes.findValues(NAME2), receivedAttributes.findValues(NAME2));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project atlasmap by atlasmap.
the class JsonFieldWriter method createParentNode.
private ObjectNode createParentNode(ObjectNode parentNode, String parentSegment, String segment) {
if (LOG.isDebugEnabled()) {
LOG.debug("Creating parent node '" + segment + "' under previous parent '" + parentSegment + "' (" + parentNode.getClass().getName() + ")");
}
ObjectNode childNode = null;
String cleanedSegment = AtlasPath.cleanPathSegment(segment);
if (AtlasPath.isCollectionSegment(segment)) {
ArrayNode arrayChild = parentNode.putArray(cleanedSegment);
int index = AtlasPath.indexOfSegment(segment);
if (arrayChild.size() < (index + 1)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Object Array is too small, resizing to accomodate index: " + index + ", current array: " + arrayChild);
}
// the index available
while (arrayChild.size() < (index + 1)) {
arrayChild.addObject();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Object Array after resizing: " + arrayChild);
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Created wrapper parent array node '" + segment + "': " + arrayChild);
}
childNode = (ObjectNode) arrayChild.get(index);
} else {
childNode = parentNode.putObject(cleanedSegment);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Parent Node '" + parentSegment + "' after adding child parent node '" + segment + "':" + parentNode);
}
return childNode;
}
Aggregations