private static GraphTraversal<Vertex, Long> getTraversalWithLambda(final GraphTraversalSource g) { assumeThat("This test is not enabled for this ScriptEngine: " + ENGINE_TO_TEST, ENGINE_TO_TEST, anyOf(is("gremlin-python"), is("gremlin-jython"), is("gremlin-groovy"))); if (ENGINE_TO_TEST.equals("gremlin-groovy")) return g.V().out("created").map(Lambda.function("{x -> x.get().values('name')}")).count(); else if (ENGINE_TO_TEST.equals("gremlin-python") || ENGINE_TO_TEST.equals("gremlin-jython")) return g.V().out("created").map(Lambda.function("x : x.get().values('name')")).count(); else throw new RuntimeException("The " + ENGINE_TO_TEST + " ScriptEngine is not supported by this test"); }
@Test public void testReadGraphOfTheGods() { GraphOfTheGodsFactory.load(graph, null, true); assertEquals(12L, (long) graph.traversal().V().count().next()); Graph g = GraphFactory.open("target/test-classes/cassandra-read.properties"); GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class)); assertEquals(12L, (long) t.V().count().next()); }
@Test public void testReadWideVertexWithManyProperties() { int numProps = 1 << 16; long numV = 1; mgmt.makePropertyKey("p").cardinality(Cardinality.LIST).dataType(Integer.class).make(); mgmt.commit(); finishSchema(); for (int j = 0; j < numV; j++) { Vertex v = graph.addVertex(); for (int i = 0; i < numProps; i++) { v.property("p", i); } } graph.tx().commit(); assertEquals(numV, (long) graph.traversal().V().count().next()); Map<String, Object> propertiesOnVertex = graph.traversal().V().valueMap().next(); List<?> valuesOnP = (List)propertiesOnVertex.values().iterator().next(); assertEquals(numProps, valuesOnP.size()); Graph g = GraphFactory.open("target/test-classes/cassandra-read.properties"); GraphTraversalSource t = g.traversal(GraphTraversalSource.computer(SparkGraphComputer.class)); assertEquals(numV, (long) t.V().count().next()); propertiesOnVertex = t.V().valueMap().next(); valuesOnP = (List)propertiesOnVertex.values().iterator().next(); assertEquals(numProps, valuesOnP.size()); }
@Test @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ) public void g_io_readXjsonX() throws IOException { final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphSONResourceAccess.class, "tinkerpop-modern-v3d0.json", "").getAbsolutePath().replace('\\', '/'); final Traversal<Object,Object> traversal = get_g_io_readXjsonX(fileToRead); printTraversalForm(traversal); traversal.iterate(); if (graph instanceof RemoteGraph) { assertEquals(6L, g.V().count().next().longValue()); assertEquals(6L, g.E().count().next().longValue()); } else { IoTest.assertModernGraph(graph, false, true); } }
@Test @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ) public void g_io_readXxmlX() throws IOException { final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/'); final Traversal<Object,Object> traversal = get_g_io_readXxmlX(fileToRead); printTraversalForm(traversal); traversal.iterate(); if (graph instanceof RemoteGraph) { assertEquals(6L, g.V().count().next().longValue()); assertEquals(6L, g.E().count().next().longValue()); } else { IoTest.assertModernGraph(graph, false, true); } }
@Test @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_READ) public void g_io_read_withXreader_graphmlX() throws IOException { final String fileToRead = TestHelper.generateTempFileFromResource(ReadTest.class, GraphMLResourceAccess.class, "tinkerpop-modern.xml", "").getAbsolutePath().replace('\\', '/'); final Traversal<Object,Object> traversal = get_g_io_read_withXreader_graphmlX(fileToRead); printTraversalForm(traversal); traversal.iterate(); if (graph instanceof RemoteGraph) { assertEquals(6L, g.V().count().next().longValue()); assertEquals(6L, g.E().count().next().longValue()); } else { IoTest.assertModernGraph(graph, false, true); } }