Package com.tinkerpop.gremlin.structure

Examples of com.tinkerpop.gremlin.structure.Graph$Features$EdgePropertyFeatures


        assertEquals("b", innerJsonObject.optString("a"));
    }

    @Test
    public void serializeHiddenProperties() throws Exception {
        final Graph g = TinkerGraph.open();
        final Vertex v = g.addVertex("abc", 123);
        v.property(Graph.Key.hide("hidden"), "stephen");

        final Iterable iterable = g.V().toList();
        final String results = SERIALIZER.serializeResponseAsString(ResponseMessage.build(msg).result(iterable).create());
        final JSONObject json = new JSONObject(results);

        assertNotNull(json);
        assertEquals(msg.getRequestId().toString(), json.getString(SerTokens.TOKEN_REQUEST));
View Full Code Here


        assertEquals(1, hiddens.length());
    }

    @Test
    public void serializeEdge() 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<Edge> iterable = g.E().toList();
        final String results = SERIALIZER.serializeResponseAsString(ResponseMessage.build(msg).result(iterable).create());

        final JSONObject json = new JSONObject(results);

        assertNotNull(json);
View Full Code Here

    }

    @Test
    public void serializeToJsonIteratorWithEmbeddedMap() throws Exception {
        final Graph g = TinkerGraph.open();
        final Vertex v = g.addVertex();
        final Map<String, Object> map = new HashMap<>();
        map.put("x", 500);
        map.put("y", "some");

        final ArrayList<Object> friends = new ArrayList<>();
        friends.add("x");
        friends.add(5);
        friends.add(map);

        v.property("friends", friends);

        final Iterable iterable = g.V().toList();
        final String results = SERIALIZER.serializeResponseAsString(ResponseMessage.build(msg).result(iterable).create());
        final JSONObject json = new JSONObject(results);

        assertNotNull(json);
        assertEquals(msg.getRequestId().toString(), json.getString(SerTokens.TOKEN_REQUEST));
View Full Code Here

* @author Joshua Shinavier (http://fortytwo.net)
*/
public class VertexStreamIteratorTest {
    @Test
    public void testAll() throws Exception {
        Graph g = TinkerFactory.createClassic();

        try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
            final KryoWriter writer = KryoWriter.build().create();
            writer.writeVertices(os, g.V(), Direction.BOTH);

            final AtomicInteger called = new AtomicInteger(0);
            final KryoReader reader = KryoReader.build()
                    .workingDirectory(File.separator + "tmp").create();

            VertexStreamIterator vsi = new VertexStreamIterator(new ByteArrayInputStream(os.toByteArray()), reader);

            boolean found = false;
            while (vsi.hasNext()) {
                Vertex v = vsi.next();

                //System.out.println("v = " + v);
                //System.out.println("\tin edges: " + count(v.in().toList()));
                //System.out.println("\tout edges: " + count(v.out().toList()));
                String name = v.<String>property("name").value();
                //System.out.println("name: " + name);
                if (name.equals("ripple")) {
                    found = true;
                    assertEquals(1, count(v.in().toList()));
                    assertEquals(0, count(v.out().toList()));
                }

                called.incrementAndGet();
            }
            assertTrue(found);

            assertEquals(count(g.V().toList()), called.get());
        }
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.structure.Graph$Features$EdgePropertyFeatures

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.