use of org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader in project janusgraph by JanusGraph.
the class JanusGraphSONModuleTest method graphsonSerializationTest.
private void graphsonSerializationTest(GraphTraversal[] traversals, GraphSONVersion version) throws Exception {
final GraphSONMapper mapper = GraphSONMapper.build().version(version).typeInfo(TypeInfo.PARTIAL_TYPES).addRegistry(JanusGraphIoRegistry.instance()).create();
final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create();
final GraphSONReader reader = GraphSONReader.build().mapper(mapper).create();
for (GraphTraversal traversal : traversals) {
Bytecode expectedBytecode = traversal.asAdmin().getBytecode();
ByteArrayOutputStream serializationStream = new ByteArrayOutputStream();
writer.writeObject(serializationStream, expectedBytecode);
ByteArrayInputStream inputStream = new ByteArrayInputStream(serializationStream.toByteArray());
Bytecode result = reader.readObject(inputStream, Bytecode.class);
assertEquals(expectedBytecode, result);
}
}
Aggregations