Package com.tinkerpop.gremlin.structure

Examples of com.tinkerpop.gremlin.structure.Edge$Exceptions


    @Test
    @LoadGraphWith(MODERN)
    public void g_v4_bothEXknows_createdX_localLimitX1X() {
        final Traversal<Vertex, Edge> traversal = get_g_v4_bothEXknows_createdX_localLimitX1X(convertToVertexId("josh"));
        printTraversalForm(traversal);
        final Edge edge = traversal.next();
        assertTrue(edge.label().equals("created") || edge.label().equals("knows"));
        assertTrue(edge.value("weight").equals(1.0d) || edge.value("weight").equals(0.4d));
        assertFalse(traversal.hasNext());
    }
View Full Code Here


        printTraversalForm(traversal);
        int counter = 0;
        final Map<Vertex, Long> map = new HashMap<>();
        while (traversal.hasNext()) {
            counter++;
            final Edge edge = traversal.next();
            MapHelper.incr(map, edge.iterators().vertexIterator(Direction.OUT).next(), 1l);
        }
        assertEquals(3, map.size());
        assertEquals(5, counter);
        map.forEach((k, v) -> {
            if (k.id().equals(convertToVertexId("marko"))) {
View Full Code Here

    @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);
        assertEquals(msg.getRequestId().toString(), json.getString(SerTokens.TOKEN_REQUEST));
        final JSONArray converted = json.getJSONObject(SerTokens.TOKEN_RESULT).getJSONArray(SerTokens.TOKEN_DATA);

        assertNotNull(converted);
        assertEquals(1, converted.length());

        final JSONObject edgeAsJson = converted.optJSONObject(0);
        assertNotNull(edgeAsJson);

        assertEquals(((Long) e.id()).intValue(), edgeAsJson.get(GraphSONTokens.ID))// lossy
        assertEquals(((Long) v1.id()).intValue(), edgeAsJson.get(GraphSONTokens.OUT));// lossy
        assertEquals(((Long) v2.id()).intValue(), edgeAsJson.get(GraphSONTokens.IN)); // lossy
        assertEquals(e.label(), edgeAsJson.get(GraphSONTokens.LABEL));
        assertEquals(GraphSONTokens.EDGE, edgeAsJson.get(GraphSONTokens.TYPE));

        final JSONObject properties = edgeAsJson.optJSONObject(GraphSONTokens.PROPERTIES);
        assertNotNull(properties);
        assertEquals(123, properties.getInt("abc"));
View Full Code Here

        }

        if (ElementHelper.areEqual(outV,inV)) {
            final Iterator<Edge> itty = outV.iterators().edgeIterator(Direction.OUT, detachedEdge.label());
            while (itty.hasNext()) {
                final Edge e = itty.next();
                if (ElementHelper.areEqual(detachedEdge, e))
                    return e;
            }
        }

        final Edge e = outV.addEdge(detachedEdge.label(), inV, T.id, detachedEdge.id());
        detachedEdge.properties.entrySet().forEach(kv ->
                        kv.getValue().forEach(p -> e.<Object>property(kv.getKey(), p.value()))
        );

        return e;
    }
View Full Code Here

        final boolean hasEdges = vertexEdges.hasNext();
        kryo.writeObject(output, d);
        output.writeBoolean(hasEdges);

        while (vertexEdges.hasNext()) {
            final Edge edgeToWrite = vertexEdges.next();
            writeEdgeToOutput(output, edgeToWrite);
        }

        if (hasEdges)
            kryo.writeClassAndObject(output, EdgeTerminator.INSTANCE);
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.structure.Edge$Exceptions

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.