本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens类的典型用法代码示例。如果您正苦于以下问题:Java GraphSONTokens类的具体用法?Java GraphSONTokens怎么用?Java GraphSONTokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphSONTokens类属于org.apache.tinkerpop.gremlin.structure.io.graphson包,在下文中一共展示了GraphSONTokens类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldSerializeEdgeProperty
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void shouldSerializeEdgeProperty() throws Exception {
final Graph g = TinkerGraph.open();
final Vertex v1 = g.addVertex();
final Vertex v2 = g.addVertex();
final Edge e = v1.addEdge("test", v2);
e.property("abc", 123);
final Iterable<Property<Object>> iterable = IteratorUtils.list(e.properties("abc"));
final String results = SERIALIZER.serializeResponseAsString(ResponseMessage.build(msg).result(iterable).create());
final JsonNode json = mapper.readTree(results);
assertNotNull(json);
assertEquals(msg.getRequestId().toString(), json.get(SerTokens.TOKEN_REQUEST).asText());
final JsonNode converted = json.get(SerTokens.TOKEN_RESULT).get(SerTokens.TOKEN_DATA);
assertNotNull(converted);
assertEquals(1, converted.size());
final JsonNode propertyAsJson = converted.get(0);
assertNotNull(propertyAsJson);
assertEquals(123, propertyAsJson.get(GraphSONTokens.VALUEPROP).get("value").get(GraphSONTokens.VALUEPROP).asInt());
}
开发者ID:apache,项目名称:tinkerpop,代码行数:26,代码来源:GraphSONMessageSerializerV2d0Test.java
示例2: shouldSerializeToJsonMapWithElementForKey
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void shouldSerializeToJsonMapWithElementForKey() throws Exception {
final TinkerGraph graph = TinkerFactory.createClassic();
final GraphTraversalSource g = graph.traversal();
final Map<Vertex, Integer> map = new HashMap<>();
map.put(g.V().has("name", "marko").next(), 1000);
final String results = SERIALIZER.serializeResponseAsString(ResponseMessage.build(msg).result(map).create());
final JsonNode json = mapper.readTree(results);
assertNotNull(json);
assertEquals(msg.getRequestId().toString(), json.get(SerTokens.TOKEN_REQUEST).asText());
final JsonNode converted = json.get(SerTokens.TOKEN_RESULT).get(SerTokens.TOKEN_DATA);
assertNotNull(converted);
// with no embedded types the key (which is a vertex) simply serializes out to an id
// {"result":{"1":1000},"code":200,"requestId":"2d62161b-9544-4f39-af44-62ec49f9a595","type":0}
assertEquals(1000, converted.get("1").get(GraphSONTokens.VALUEPROP).asInt());
}
开发者ID:apache,项目名称:tinkerpop,代码行数:21,代码来源:GraphSONMessageSerializerV2d0Test.java
示例3: serialize
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Override
public void serialize(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeFieldName(GraphSONTokens.VERTICES);
jsonGenerator.writeStartArray();
final Iterator<Vertex> vertices = graph.vertices();
while (vertices.hasNext()) {
serializerProvider.defaultSerializeValue(vertices.next(), jsonGenerator);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeFieldName(GraphSONTokens.EDGES);
jsonGenerator.writeStartArray();
final Iterator<Edge> edges = graph.edges();
while (edges.hasNext()) {
serializerProvider.defaultSerializeValue(edges.next(), jsonGenerator);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject();
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerIoRegistryV3d0.java
示例4: shouldSerializeTraversalMetrics
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Ignore
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final TraversalMetrics tm = (TraversalMetrics) g.V().both().profile().next();
final String json = mapper.writeValueAsString(tm);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
assertTrue(m.containsKey(GraphSONTokens.DURATION));
assertTrue(m.containsKey(GraphSONTokens.METRICS));
final List<Map<String, Object>> metrics = (List<Map<String, Object>>) m.get(GraphSONTokens.METRICS);
assertEquals(2, metrics.size());
final Map<String, Object> metrics0 = metrics.get(0);
assertTrue(metrics0.containsKey(GraphSONTokens.ID));
assertTrue(metrics0.containsKey(GraphSONTokens.NAME));
assertTrue(metrics0.containsKey(GraphSONTokens.COUNTS));
assertTrue(metrics0.containsKey(GraphSONTokens.DURATION));
}
开发者ID:rayokota,项目名称:hgraphdb,代码行数:22,代码来源:CustomTest.java
示例5: ser
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
public void ser(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator,
final SerializerProvider serializerProvider,
final TypeSerializer typeSerializer) throws IOException, JsonProcessingException {
jsonGenerator.writeStartObject();
if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, responseMessage.getRequestId() != null ? responseMessage.getRequestId().toString() : null);
jsonGenerator.writeObjectFieldStart(SerTokens.TOKEN_STATUS);
if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
jsonGenerator.writeStringField(SerTokens.TOKEN_MESSAGE, responseMessage.getStatus().getMessage());
jsonGenerator.writeNumberField(SerTokens.TOKEN_CODE, responseMessage.getStatus().getCode().getValue());
jsonGenerator.writeObjectField(SerTokens.TOKEN_ATTRIBUTES, responseMessage.getStatus().getAttributes());
jsonGenerator.writeEndObject();
jsonGenerator.writeObjectFieldStart(SerTokens.TOKEN_RESULT);
if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
if (null == responseMessage.getResult().getData())
jsonGenerator.writeNullField(SerTokens.TOKEN_DATA);
else
GraphSONUtil.writeWithType(SerTokens.TOKEN_DATA, responseMessage.getResult().getData(), jsonGenerator, serializerProvider, typeSerializer);
jsonGenerator.writeObjectField(SerTokens.TOKEN_META, responseMessage.getResult().getMeta());
jsonGenerator.writeEndObject();
jsonGenerator.writeEndObject();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:AbstractGraphSONMessageSerializerV1d0.java
示例6: readStarGraphEdges
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
/**
* A helper function for reading vertex edges from a serialized {@link StarGraph} (i.e. a {@link Map}) generated by
* {@link StarGraphGraphSONSerializer}.
*/
public static void readStarGraphEdges(final Function<Attachable<Edge>, Edge> edgeMaker,
final StarGraph starGraph,
final Map<String, Object> vertexData,
final String direction) throws IOException {
final Map<String, List<Map<String,Object>>> edgeDatas = (Map<String, List<Map<String,Object>>>) vertexData.get(direction);
for (Map.Entry<String, List<Map<String,Object>>> edgeData : edgeDatas.entrySet()) {
for (Map<String,Object> inner : edgeData.getValue()) {
final StarGraph.StarEdge starEdge;
if (direction.equals(GraphSONTokens.OUT_E))
starEdge = (StarGraph.StarEdge) starGraph.getStarVertex().addOutEdge(edgeData.getKey(), starGraph.addVertex(T.id, inner.get(GraphSONTokens.IN)), T.id, inner.get(GraphSONTokens.ID));
else
starEdge = (StarGraph.StarEdge) starGraph.getStarVertex().addInEdge(edgeData.getKey(), starGraph.addVertex(T.id, inner.get(GraphSONTokens.OUT)), T.id, inner.get(GraphSONTokens.ID));
if (inner.containsKey(GraphSONTokens.PROPERTIES)) {
final Map<String, Object> edgePropertyData = (Map<String, Object>) inner.get(GraphSONTokens.PROPERTIES);
for (Map.Entry<String, Object> epd : edgePropertyData.entrySet()) {
starEdge.property(epd.getKey(), epd.getValue());
}
}
if (edgeMaker != null) edgeMaker.apply(starEdge);
}
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:29,代码来源:StarGraphGraphSONSerializer.java
示例7: readStarGraphVertex
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
/**
* A helper function for reading a serialized {@link StarGraph} from a {@link Map} generated by
* {@link StarGraphGraphSONSerializer}.
*/
public static StarGraph readStarGraphVertex(final Map<String, Object> vertexData) throws IOException {
final StarGraph starGraph = StarGraph.open();
starGraph.addVertex(T.id, vertexData.get(GraphSONTokens.ID), T.label, vertexData.get(GraphSONTokens.LABEL));
if (vertexData.containsKey(GraphSONTokens.PROPERTIES)) {
final Map<String, List<Map<String, Object>>> properties = (Map<String, List<Map<String, Object>>>) vertexData.get(GraphSONTokens.PROPERTIES);
for (Map.Entry<String, List<Map<String, Object>>> property : properties.entrySet()) {
for (Map<String, Object> p : property.getValue()) {
final StarGraph.StarVertexProperty vp = (StarGraph.StarVertexProperty) starGraph.getStarVertex().property(VertexProperty.Cardinality.list, property.getKey(), p.get(GraphSONTokens.VALUE), T.id, p.get(GraphSONTokens.ID));
if (p.containsKey(GraphSONTokens.PROPERTIES)) {
final Map<String, Object> edgePropertyData = (Map<String, Object>) p.get(GraphSONTokens.PROPERTIES);
for (Map.Entry<String, Object> epd : edgePropertyData.entrySet()) {
vp.property(epd.getKey(), epd.getValue());
}
}
}
}
}
return starGraph;
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:StarGraphGraphSONSerializer.java
示例8: shouldSerializeDeserialize
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void shouldSerializeDeserialize() throws Exception {
final GryoMapper mapper = GryoMapper.build().create();
final Kryo kryo = mapper.createMapper();
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output out = new Output(stream);
final Map<String,Object> props = new HashMap<>();
final List<Map<String, Object>> propertyNames = new ArrayList<>(1);
final Map<String,Object> propertyName = new HashMap<>();
propertyName.put(GraphSONTokens.ID, "x");
propertyName.put(GraphSONTokens.KEY, "x");
propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work");
propertyNames.add(propertyName);
props.put("x", propertyNames);
final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);
kryo.writeClassAndObject(out, v);
try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
final Input input = new Input(inputStream);
final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input);
assertEquals("no-way-this-will-ever-work", readX.value("x"));
}
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:GryoMapperTest.java
示例9: should200OnPOSTWithGremlinJsonEndcodedBodyWithTinkerGraphResult
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithGremlinJsonEndcodedBodyWithTinkerGraphResult() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost("http://localhost:8182");
httppost.addHeader("Content-Type", "application/json");
httppost.setEntity(new StringEntity("{\"gremlin\":\"org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.createModern()\"}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode resultJson = mapper.readTree(json);
final JsonNode data = resultJson.get("result").get("data");
assertEquals(1, data.size());
final List<JsonNode> vertices = data.get(0).findValues(GraphSONTokens.VERTICES);
final List<JsonNode> edges = data.get(0).findValues(GraphSONTokens.EDGES);
assertEquals(6, vertices.get(0).size());
assertEquals(6, edges.get(0).size());
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinServerHttpIntegrateTest.java
示例10: shouldSerializeVertex
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final Vertex v = graph.vertices(convertToVertexId("marko")).next();
final String json = mapper.writeValueAsString(v);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
assertEquals(GraphSONTokens.VERTEX, m.get(GraphSONTokens.TYPE));
assertEquals(v.label(), m.get(GraphSONTokens.LABEL));
assertNotNull(m.get(GraphSONTokens.ID));
final Map<String,List<Map<String,Object>>> properties = (Map<String,List<Map<String,Object>>>) m.get(GraphSONTokens.PROPERTIES);
assertEquals(v.value("name").toString(), properties.get("name").get(0).get(GraphSONTokens.VALUE).toString());
assertEquals((Integer) v.value("age"), properties.get("age").get(0).get(GraphSONTokens.VALUE));
assertEquals(1, properties.get("name").size());
assertEquals(1, properties.get("age").size());
assertEquals(2, properties.size());
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:SerializationTest.java
示例11: shouldSerializeTraversalMetrics
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
final TraversalMetrics tm = (TraversalMetrics) g.V().both().profile().next();
final String json = mapper.writeValueAsString(tm);
final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
assertTrue(m.containsKey(GraphSONTokens.DURATION));
assertTrue(m.containsKey(GraphSONTokens.METRICS));
final List<Map<String, Object>> metrics = (List<Map<String, Object>>) m.get(GraphSONTokens.METRICS);
assertEquals(2, metrics.size());
final Map<String, Object> metrics0 = metrics.get(0);
assertTrue(metrics0.containsKey(GraphSONTokens.ID));
assertTrue(metrics0.containsKey(GraphSONTokens.NAME));
assertTrue(metrics0.containsKey(GraphSONTokens.COUNTS));
assertTrue(metrics0.containsKey(GraphSONTokens.DURATION));
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:SerializationTest.java
示例12: readStarGraphEdges
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
/**
* A helper function for reading vertex edges from a serialized {@link org.apache.tinkerpop.gremlin.structure.util.star.StarGraph} (i.e. a {@link java.util.Map}) generated by
* {@link org.apache.tinkerpop.gremlin.structure.util.star.StarGraphGraphSONSerializerV1d0}.
*/
public static void readStarGraphEdges(final Function<Attachable<Edge>, Edge> edgeMaker,
final StarGraph starGraph,
final Map<String, Object> vertexData,
final String direction) throws IOException {
final Map<String, List<Map<String,Object>>> edgeDatas = (Map<String, List<Map<String,Object>>>) vertexData.get(direction);
for (Map.Entry<String, List<Map<String,Object>>> edgeData : edgeDatas.entrySet()) {
for (Map<String,Object> inner : edgeData.getValue()) {
final StarGraph.StarEdge starEdge;
if (direction.equals(GraphSONTokens.OUT_E))
starEdge = (StarGraph.StarEdge) starGraph.getStarVertex().addOutEdge(edgeData.getKey(), starGraph.addVertex(T.id, inner.get(GraphSONTokens.IN)), T.id, inner.get(GraphSONTokens.ID));
else
starEdge = (StarGraph.StarEdge) starGraph.getStarVertex().addInEdge(edgeData.getKey(), starGraph.addVertex(T.id, inner.get(GraphSONTokens.OUT)), T.id, inner.get(GraphSONTokens.ID));
if (inner.containsKey(GraphSONTokens.PROPERTIES)) {
final Map<String, Object> edgePropertyData = (Map<String, Object>) inner.get(GraphSONTokens.PROPERTIES);
for (Map.Entry<String, Object> epd : edgePropertyData.entrySet()) {
starEdge.property(epd.getKey(), epd.getValue());
}
}
if (edgeMaker != null) edgeMaker.apply(starEdge);
}
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:29,代码来源:StarGraphGraphSONDeserializer.java
示例13: readStarGraphVertex
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
/**
* A helper function for reading a serialized {@link org.apache.tinkerpop.gremlin.structure.util.star.StarGraph} from a {@link java.util.Map} generated by
* {@link org.apache.tinkerpop.gremlin.structure.util.star.StarGraphGraphSONSerializerV1d0}.
*/
public static StarGraph readStarGraphVertex(final Map<String, Object> vertexData) throws IOException {
final StarGraph starGraph = StarGraph.open();
starGraph.addVertex(T.id, vertexData.get(GraphSONTokens.ID), T.label, vertexData.get(GraphSONTokens.LABEL));
if (vertexData.containsKey(GraphSONTokens.PROPERTIES)) {
final Map<String, List<Map<String, Object>>> properties = (Map<String, List<Map<String, Object>>>) vertexData.get(GraphSONTokens.PROPERTIES);
for (Map.Entry<String, List<Map<String, Object>>> property : properties.entrySet()) {
for (Map<String, Object> p : property.getValue()) {
final StarGraph.StarVertexProperty vp = (StarGraph.StarVertexProperty) starGraph.getStarVertex().property(VertexProperty.Cardinality.list, property.getKey(), p.get(GraphSONTokens.VALUE), T.id, p.get(GraphSONTokens.ID));
if (p.containsKey(GraphSONTokens.PROPERTIES)) {
final Map<String, Object> edgePropertyData = (Map<String, Object>) p.get(GraphSONTokens.PROPERTIES);
for (Map.Entry<String, Object> epd : edgePropertyData.entrySet()) {
vp.property(epd.getKey(), epd.getValue());
}
}
}
}
}
return starGraph;
}
开发者ID:apache,项目名称:tinkerpop,代码行数:25,代码来源:StarGraphGraphSONDeserializer.java
示例14: shouldSerializeDeserialize
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void shouldSerializeDeserialize() throws Exception {
final GryoMapper mapper = builder.get().create();
final Kryo kryo = mapper.createMapper();
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output out = new Output(stream);
final Map<String,Object> props = new HashMap<>();
final List<Map<String, Object>> propertyNames = new ArrayList<>(1);
final Map<String,Object> propertyName = new HashMap<>();
propertyName.put(GraphSONTokens.ID, "x");
propertyName.put(GraphSONTokens.KEY, "x");
propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work");
propertyNames.add(propertyName);
props.put("x", propertyNames);
final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);
kryo.writeClassAndObject(out, v);
try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
final Input input = new Input(inputStream);
final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input);
assertEquals("no-way-this-will-ever-work", readX.value("x"));
}
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:27,代码来源:GryoMapperTest.java
示例15: should200OnPOSTWithAuthorizationHeader
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithAuthorizationHeader() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
httppost.addHeader("Content-Type", "application/json");
httppost.addHeader("Authorization", "Basic " + encoder.encodeToString("stephen:password".getBytes()));
httppost.setEntity(new StringEntity("{\"gremlin\":\"1-1\"}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode node = mapper.readTree(json);
assertEquals(0, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).intValue());
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GremlinServerHttpIntegrateTest.java
示例16: should200OnPOSTWithAuthorizationHeaderExplicitHandlerSetting
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithAuthorizationHeaderExplicitHandlerSetting() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
httppost.addHeader("Content-Type", "application/json");
httppost.addHeader("Authorization", "Basic " + encoder.encodeToString("stephen:password".getBytes()));
httppost.setEntity(new StringEntity("{\"gremlin\":\"1-1\"}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode node = mapper.readTree(json);
assertEquals(0, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).intValue());
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GremlinServerHttpIntegrateTest.java
示例17: should200OnPOSTWithGremlinJsonEndcodedBodyForJavaTime
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithGremlinJsonEndcodedBodyForJavaTime() throws Exception {
// basic test of java.time.* serialization over JSON from the server perspective. more complete tests
// exist in gremlin-core
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
httppost.addHeader("Content-Type", "application/json");
httppost.setEntity(new StringEntity("{\"gremlin\":\"java.time.Instant.MAX\"}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode node = mapper.readTree(json);
assertEquals(Instant.MAX, Instant.parse(node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).asText()));
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:GremlinServerHttpIntegrateTest.java
示例18: should200OnPOSTWithGremlinJsonEndcodedBodyWithTinkerGraphResult
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithGremlinJsonEndcodedBodyWithTinkerGraphResult() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
httppost.addHeader("Content-Type", "application/json");
httppost.setEntity(new StringEntity("{\"gremlin\":\"org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.createModern()\"}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode resultJson = mapper.readTree(json);
final JsonNode data = resultJson.get("result").get("data");
assertEquals(1, data.get(GraphSONTokens.VALUEPROP).size());
assertEquals(6, data.get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).get(GraphSONTokens.VERTICES).size());
assertEquals(6, data.get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).get(GraphSONTokens.EDGES).size());
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:GremlinServerHttpIntegrateTest.java
示例19: should200OnPOSTWithGremlinJsonEndcodedBodyAndArrayBindings
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithGremlinJsonEndcodedBodyAndArrayBindings() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
httppost.addHeader("Content-Type", "application/json");
httppost.setEntity(new StringEntity("{\"gremlin\":\"x\", \"bindings\":{\"x\":[1,2,3]}}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode node = mapper.readTree(json);
assertEquals(true, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).isArray());
assertEquals(1, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).intValue());
assertEquals(2, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(1).get(GraphSONTokens.VALUEPROP).intValue());
assertEquals(3, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(2).get(GraphSONTokens.VALUEPROP).intValue());
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:GremlinServerHttpIntegrateTest.java
示例20: should200OnPOSTWithGremlinJsonEndcodedBodyAndMapBindings
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens; //导入依赖的package包/类
@Test
public void should200OnPOSTWithGremlinJsonEndcodedBodyAndMapBindings() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpPost httppost = new HttpPost(TestClientFactory.createURLString());
httppost.addHeader("Content-Type", "application/json");
httppost.setEntity(new StringEntity("{\"gremlin\":\"x\", \"bindings\":{\"x\":{\"y\":1}}}", Consts.UTF_8));
try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("application/json", response.getEntity().getContentType().getValue());
final String json = EntityUtils.toString(response.getEntity());
final JsonNode node = mapper.readTree(json);
assertEquals("g:Map", node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(0).get("@type").asText());
assertEquals(1, node.get("result").get("data").get(GraphSONTokens.VALUEPROP).get(0).get(GraphSONTokens.VALUEPROP).get(1).get(GraphSONTokens.VALUEPROP).asInt());
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GremlinServerHttpIntegrateTest.java
注:本文中的org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论