Refine search
@Test public void testSimpleTinkerPopTraversal() { Vertex v1 = graph.addVertex("name", "josh"); Vertex v2 = graph.addVertex("name", "lop"); v1.addEdge("created", v2); //graph.tx().commit(); Object id = graph.traversal().V().has("name", "josh").outE("created").as("e").inV().has("name", "lop").<Edge>select("e").next().id(); assertNotNull(id); }
@Test public void testSimpleTinkerPopTraversal() { Vertex v1 = graph.addVertex("name", "josh"); Vertex v2 = graph.addVertex("name", "lop"); v1.addEdge("created", v2); //graph.tx().commit(); Object id = graph.traversal().V().has("name", "josh").outE("created").as("e").inV().has("name", "lop").<Edge>select("e").next().id(); assertNotNull(id); }
@Test @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldSerializePath() throws Exception { final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper(); final Path p = g.V(convertToVertexId("marko")).as("a").outE().as("b").inV().as("c").path() .filter(t -> ((Vertex) t.get().objects().get(2)).value("name").equals("lop")).next(); final String json = mapper.writeValueAsString(p); final Map<String, Object> m = mapper.readValue(json, mapTypeReference); assertEquals(2, m.size()); final List<List<String>> labels = (List<List<String>>) m.get(GraphSONTokens.LABELS); assertEquals(3, labels.size()); assertEquals("a", labels.get(0).get(0)); assertEquals(1, labels.get(0).size()); assertEquals("b", labels.get(1).get(0)); assertEquals(1, labels.get(1).size()); assertEquals("c", labels.get(2).get(0)); assertEquals(1, labels.get(2).size()); final List<Object> objects = (List<Object>) m.get(GraphSONTokens.OBJECTS); assertEquals(3, objects.size()); assertEquals("marko", ((List<Map>) ((Map) ((Map) objects.get(0)).get(GraphSONTokens.PROPERTIES)).get("name")).get(0).get(GraphSONTokens.VALUE).toString()); assertEquals("created", ((Map) objects.get(1)).get(GraphSONTokens.LABEL)); assertEquals("lop", ((List<Map>) ((Map) ((Map) objects.get(2)).get(GraphSONTokens.PROPERTIES)).get("name")).get(0).get(GraphSONTokens.VALUE).toString()); }
@Parameterized.Parameters(name = "expectInterruption({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"g_V", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t}, {"g_V_out", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.out()}, {"g_V_outE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.outE()}, {"g_V_in", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.in()}, {"g_V_inE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.inE()}, {"g_V_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.properties()}, {"g_E", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t}, {"g_E_outV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.outV()}, {"g_E_inV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.inV()}, {"g_E_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.properties()}, }); }