TinkerGraph implements Graph { @Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV1d0.instance())).create(); else if (builder.requiresVersion(GraphSONVersion.V2_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV2d0.instance())).create(); else return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV3d0.instance())).create(); } private  TinkerGraph(final Configuration configuration); static TinkerGraph open(); static TinkerGraph open(final Configuration configuration); @Override Vertex addVertex(final Object... keyValues); @Override C compute(final Class<C> graphComputerClass); @Override GraphComputer compute(); @Override Variables variables(); @Override I io(final Io.Builder<I> builder); @Override String toString(); void clear(); @Override void close(); @Override Transaction tx(); @Override Configuration configuration(); @Override Iterator<Vertex> vertices(final Object... vertexIds); @Override Iterator<Edge> edges(final Object... edgeIds); @Override Features features(); void createIndex(final String key, final Class<E> elementClass); void dropIndex(final String key, final Class<E> elementClass); Set<String> getIndexedKeys(final Class<E> elementClass); static final String GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER; static final String GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER; static final String GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER; static final String GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY; static final String GREMLIN_TINKERGRAPH_GRAPH_LOCATION; static final String GREMLIN_TINKERGRAPH_GRAPH_FORMAT; static final String GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES; }
@Test public void shouldSerializeTinkerGraphToGryo() throws Exception { final TinkerGraph graph = TinkerFactory.createModern(); try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { graph.io(IoCore.gryo()).writer().create().writeObject(out, graph); final byte[] b = out.toByteArray(); try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) { final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class); IoTest.assertModernGraph(target, true, false); } } }
@Test public void shouldSerializeTinkerGraphWithMultiPropertiesToGryo() throws Exception { final TinkerGraph graph = TinkerFactory.createTheCrew(); try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { graph.io(IoCore.gryo()).writer().create().writeObject(out, graph); final byte[] b = out.toByteArray(); try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(b)) { final TinkerGraph target = graph.io(IoCore.gryo()).reader().create().readObject(inputStream, TinkerGraph.class); IoTest.assertCrewGraph(target, false); } } }
@Test public void shouldSerializeTinkerGraphToGraphSON() throws Exception { final TinkerGraph graph = TinkerFactory.createModern(); try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { graph.io(IoCore.graphson()).writer().create().writeObject(out, graph); try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) { final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class); IoTest.assertModernGraph(target, true, false); } } }
@Test public void shouldSerializeTinkerGraphWithMultiPropertiesToGraphSON() throws Exception { final TinkerGraph graph = TinkerFactory.createTheCrew(); try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { graph.io(IoCore.graphson()).writer().create().writeObject(out, graph); try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) { final TinkerGraph target = graph.io(IoCore.graphson()).reader().create().readObject(inputStream, TinkerGraph.class); IoTest.assertCrewGraph(target, false); } } }
@Test public void shouldSerializeTinkerGraphToGraphSONWithTypes() throws Exception { final TinkerGraph graph = TinkerFactory.createModern(); final Mapper<ObjectMapper> mapper = graph.io(IoCore.graphson()).mapper().typeInfo(TypeInfo.PARTIAL_TYPES).create(); try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) { final GraphWriter writer = GraphSONWriter.build().mapper(mapper).create(); writer.writeObject(out, graph); try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) { final GraphReader reader = GraphSONReader.build().mapper(mapper).create(); final TinkerGraph target = reader.readObject(inputStream, TinkerGraph.class); IoTest.assertModernGraph(target, true, false); } } }