Package com.tinkerpop.gremlin.structure.io.graphson

Examples of com.tinkerpop.gremlin.structure.io.graphson.GraphSONReader


            final GraphSONWriter writer = GraphSONWriter.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            final DetachedVertex dv = DetachedVertex.detach(v1);
            writer.writeVertex(os, dv);

            final AtomicBoolean called = new AtomicBoolean(false);
            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, detachedVertex -> {
                    assertEquals(v1.id().toString(), detachedVertex.id().toString()); // lossy
                    assertEquals(v1.label(), detachedVertex.label());
                    assertEquals(1, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                    assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                    assertEquals("marko", detachedVertex.iterators().propertyIterator("name").next().value());
View Full Code Here


            final GraphSONWriter writer = GraphSONWriter.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            final DetachedVertex dv = DetachedVertex.detach(v1, true);
            writer.writeVertex(os, dv);

            final AtomicBoolean called = new AtomicBoolean(false);
            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, detachedVertex -> {
                    assertEquals(v1.id().toString(), detachedVertex.id().toString()); // lossy
                    assertEquals(v1.label(), detachedVertex.label());
                    assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                    assertEquals(0, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
View Full Code Here

        try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
            final GraphSONWriter writer = GraphSONWriter.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            writer.writeVertex(os, v1);

            final AtomicBoolean called = new AtomicBoolean(false);
            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, detachedVertex -> {
                    assertEquals(v1.id().toString(), detachedVertex.id().toString()); // lossy
                    assertEquals(v1.label(), detachedVertex.label());
                    assertEquals(1, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                    assertEquals(3, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                    assertEquals("a", detachedVertex.property("propsSquared").value("x"));
View Full Code Here

        try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
            final GraphSONWriter writer = GraphSONWriter.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            writer.writeVertices(os, g.V().has("age", Compare.gt, 30));

            final AtomicInteger called = new AtomicInteger(0);
            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            final BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(os.toByteArray())));
            String line = br.readLine();
            reader.readVertex(new ByteArrayInputStream(line.getBytes()),
                    detachedVertex -> {
                        called.incrementAndGet();
                        return mock(Vertex.class);
                    });

            line = br.readLine();
            reader.readVertex(new ByteArrayInputStream(line.getBytes()),
                    detachedVertex -> {
                        called.incrementAndGet();
                        return mock(Vertex.class);
                    });
View Full Code Here

            final GraphSONWriter writer = GraphSONWriter.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            writer.writeVertex(os, v1, Direction.OUT);

            final AtomicBoolean calledVertex = new AtomicBoolean(false);
            final AtomicBoolean calledEdge = new AtomicBoolean(false);
            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, Direction.OUT, detachedVertex -> {
                            assertEquals(v1.id().toString(), detachedVertex.id().toString())// lossy
                            assertEquals(v1.label(), detachedVertex.label());
                            assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                            assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                            assertEquals("marko", detachedVertex.value("name"));
View Full Code Here

            writer.writeVertex(os, v1, Direction.IN);
            os.close();

            final AtomicBoolean calledVertex = new AtomicBoolean(false);
            final AtomicBoolean calledEdge = new AtomicBoolean(false);
            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, Direction.IN, detachedVertex -> {
                            assertEquals(v1.id().toString(), detachedVertex.id().toString())// lossy
                            assertEquals(v1.label(), detachedVertex.label());
                            assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                            assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                            assertEquals("marko", detachedVertex.value("name"));
View Full Code Here

            final AtomicBoolean vertexCalled = new AtomicBoolean(false);
            final AtomicBoolean edge1Called = new AtomicBoolean(false);
            final AtomicBoolean edge2Called = new AtomicBoolean(false);

            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
                            assertEquals(v1.id().toString(), detachedVertex.id().toString())// lossy
                            assertEquals(v1.label(), detachedVertex.label());
                            assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                            assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                            assertEquals("marko", detachedVertex.value("name"));
View Full Code Here

            final AtomicBoolean vertexCalled = new AtomicBoolean(false);
            final AtomicBoolean edge1Called = new AtomicBoolean(false);
            final AtomicBoolean edge2Called = new AtomicBoolean(false);

            final GraphSONReader reader = GraphSONReader.build()
                    .customModule(graphProvider.createConfiguredGraphSONModule()).embedTypes(true).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, Direction.BOTH, detachedVertex -> {
                    assertEquals(v1.id(), graphProvider.reconstituteGraphSONIdentifier(Vertex.class, detachedVertex.id()));
                    assertEquals(v1.label(), detachedVertex.label());
                    assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                    assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                    assertEquals(v1.value("name"), detachedVertex.value("name").toString());
View Full Code Here

            writer.writeVertex(os, v1, Direction.BOTH);

            final AtomicBoolean vertexCalled = new AtomicBoolean(false);
            final AtomicBoolean edgeCalled = new AtomicBoolean(false);

            final GraphSONReader reader = GraphSONReader.build().customModule(graphProvider.createConfiguredGraphSONModule()).create();
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, Direction.IN, detachedVertex -> {
                    assertEquals(v1.id().toString(), detachedVertex.id().toString())// lossy
                    assertEquals(v1.label(), detachedVertex.label());
                    assertEquals(0, StreamFactory.stream(detachedVertex.iterators().hiddenPropertyIterator()).count());
                    assertEquals(1, StreamFactory.stream(detachedVertex.iterators().propertyIterator()).count());
                    assertEquals("marko", detachedVertex.value("name"));
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.structure.io.graphson.GraphSONReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.