org.apache.tinkerpop.gremlin.LoadGraphWith Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.LoadGraphWith. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrderTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_elementMap_orderXlocalX_byXkeys_descXunfold() {
    final Traversal<Vertex, ?> traversal = get_g_VX1X_elementMap_orderXlocalX_byXkeys_descXunfold(convertToVertexId(graph, "marko"));
    printTraversalForm(traversal);

    final Object name = traversal.next();
    assertEquals("name", getKey(name));
    final Object label = traversal.next();
    assertEquals(T.label, getKey(label));
    final Object id = traversal.next();
    assertEquals(T.id, getKey(id));
    final Object age = traversal.next();
    assertEquals("age", getKey(age));

    assertThat(traversal.hasNext(), is(false));
}
 
Example #2
Source File: VertexTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_bothE() {
    final Traversal<Vertex, Edge> traversal = get_g_VX4X_bothE(convertToVertexId("josh"));
    printTraversalForm(traversal);
    int counter = 0;
    final Set<Edge> edges = new HashSet<>();
    while (traversal.hasNext()) {
        counter++;
        final Edge edge = traversal.next();
        edges.add(edge);
        assertTrue(edge.label().equals("knows") || edge.label().equals("created"));
    }
    assertEquals(3, counter);
    assertEquals(3, edges.size());
}
 
Example #3
Source File: IoGraphTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CLASSIC)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
public void shouldMigrateClassicGraph() throws Exception {
    final Configuration configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), LoadGraphWith.GraphData.CLASSIC);
    graphProvider.clear(configuration);
    final Graph g1 = graphProvider.openTestGraph(configuration);

    final GraphReader reader = graph.io(ioBuilderToTest).reader().create();
    final GraphWriter writer = graph.io(ioBuilderToTest).writer().create();

    GraphMigrator.migrateGraph(graph, g1, reader, writer);

    IoTest.assertClassicGraph(g1, assertDouble, lossyForId);

    graphProvider.clear(g1, configuration);
}
 
Example #4
Source File: AddEdgeTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
public void g_VX1X_asXaX_outXcreatedX_addEXcreatedByX_toXaX() {
    final Traversal<Vertex, Edge> traversal = get_g_VX1X_asXaX_outXcreatedX_addEXcreatedByX_toXaX(convertToVertexId("marko"));
    printTraversalForm(traversal);
    int count = 0;
    while (traversal.hasNext()) {
        final Edge edge = traversal.next();
        assertEquals("createdBy", edge.label());
        assertEquals(0, IteratorUtils.count(edge.properties()));
        count++;

    }
    assertEquals(1, count);
    assertEquals(7, IteratorUtils.count(g.E()));
    assertEquals(6, IteratorUtils.count(g.V()));
}
 
Example #5
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_hasLabelXsoftwareX_asXnameX_asXlanguageX_asXcreatorsX_selectXname_language_creatorsX_byXnameX_byXlangX_byXinXcreatedX_name_fold_orderXlocalXX() {
    final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_hasLabelXsoftwareX_asXnameX_asXlanguageX_asXcreatorsX_selectXname_language_creatorsX_byXnameX_byXlangX_byXinXcreatedX_name_fold_orderXlocalXX();
    printTraversalForm(traversal);
    for (int i = 0; i < 2; i++) {
        assertTrue(traversal.hasNext());
        final Map<String, Object> map = traversal.next();
        assertEquals(3, map.size());
        final List<String> creators = (List<String>) map.get("creators");
        final boolean isLop = "lop".equals(map.get("name")) && "java".equals(map.get("language")) &&
                creators.size() == 3 && creators.get(0).equals("josh") && creators.get(1).equals("marko") && creators.get(2).equals("peter");
        final boolean isRipple = "ripple".equals(map.get("name")) && "java".equals(map.get("language")) &&
                creators.size() == 1 && creators.get(0).equals("josh");
        assertTrue(isLop ^ isRipple);
    }
    assertFalse(traversal.hasNext());
}
 
Example #6
Source File: PathTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_outEXcreatedX_inV_inE_outV_path() {
    final Traversal<Vertex, Path> traversal = get_g_VX1X_outEXcreatedX_inV_inE_outV_path(convertToVertexId("marko"));
    printTraversalForm(traversal);
    final List<Path> paths = traversal.toList();
    assertEquals(3, paths.size());
    for (final Path path : paths) {
        assertEquals(5, path.size());
        assertEquals(convertToVertexId("marko"), ((Vertex) path.get(0)).id());
        assertEquals(convertToEdgeId("marko", "created", "lop"), ((Edge) path.get(1)).id());
        assertEquals(convertToVertexId("lop"), ((Vertex) path.get(2)).id());
        assertEquals("created", ((Edge) path.get(3)).label());
        assertTrue(convertToVertexId("josh").equals(((Vertex) path.get(4)).id()) ||
                convertToVertexId("peter").equals(((Vertex) path.get(4)).id()) ||
                convertToVertexId("marko").equals(((Vertex) path.get(4)).id()));
    }
    assertFalse(traversal.hasNext());
}
 
Example #7
Source File: OrderTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_mapXbothE_weight_foldX_order_byXsumXlocalX_descX() {
    final Traversal<Vertex, List<Double>> traversal = get_g_V_mapXbothE_weight_foldX_order_byXsumXlocalX_descX();
    final List<List<Double>> list = traversal.toList();
    assertEquals(list.get(0).size(), 3);
    assertEquals(list.get(1).size(), 3);
    //assertEquals(list.get(2).size(),3);  // they both have value 1.0 and thus can't guarantee a tie order
    //assertEquals(list.get(3).size(),1);
    assertEquals(list.get(4).size(), 1);
    assertEquals(list.get(5).size(), 1);
    ///
    assertEquals(2.4d, list.get(0).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(1.9d, list.get(1).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(1.0d, list.get(2).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(1.0d, list.get(3).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(0.5d, list.get(4).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(0.2d, list.get(5).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
}
 
Example #8
Source File: GroupTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(GRATEFUL)
public void g_V_hasLabelXsongX_group_byXnameX_byXproperties_groupCount_byXlabelXX() {
    final Traversal<Vertex, Map<String, Map<String, Long>>> traversal = get_g_V_hasLabelXsongX_group_byXnameX_byXproperties_groupCount_byXlabelXX();
    printTraversalForm(traversal);
    final Map<String, Map<String, Long>> map = traversal.next();
    assertEquals(584, map.size());
    for (final Map.Entry<String, Map<String, Long>> entry : map.entrySet()) {
        assertEquals(entry.getKey().toUpperCase(), entry.getKey());
        final Map<String, Long> countMap = entry.getValue();
        assertEquals(3, countMap.size());
        assertEquals(1l, countMap.get("name").longValue());
        assertEquals(1l, countMap.get("songType").longValue());
        assertEquals(1l, countMap.get("performances").longValue());
    }
    assertFalse(traversal.hasNext());
}
 
Example #9
Source File: DetachedEdgeTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(GraphData.MODERN)
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
@FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
public void shouldConstructDetachedEdge() {
    g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("year", 2002);
    final DetachedEdge detachedEdge = DetachedFactory.detach(g.E(convertToEdgeId("marko", "knows", "vadas")).next(), true);
    assertEquals(convertToEdgeId("marko", "knows", "vadas"), detachedEdge.id());
    assertEquals("knows", detachedEdge.label());
    assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.OUT).next().getClass());
    assertEquals(convertToVertexId("marko"), detachedEdge.vertices(Direction.OUT).next().id());
    assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());
    assertEquals(DetachedVertex.class, detachedEdge.vertices(Direction.IN).next().getClass());
    assertEquals(convertToVertexId("vadas"), detachedEdge.vertices(Direction.IN).next().id());
    assertEquals("person", detachedEdge.vertices(Direction.IN).next().label());

    assertEquals(2, IteratorUtils.count(detachedEdge.properties()));
    assertEquals(1, IteratorUtils.count(detachedEdge.properties("year")));
    assertEquals(0.5d, detachedEdge.properties("weight").next().value());
}
 
Example #10
Source File: VertexTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_outEXknowsX_bothV_name() {
    final Traversal<Vertex, String> traversal = get_g_VX1X_outEXknowsX_bothV_name(convertToVertexId("marko"));
    printTraversalForm(traversal);
    final List<String> names = traversal.toList();
    assertEquals(4, names.size());
    assertTrue(names.contains("marko"));
    assertTrue(names.contains("josh"));
    assertTrue(names.contains("vadas"));
    names.remove("marko");
    assertEquals(3, names.size());
    names.remove("marko");
    assertEquals(2, names.size());
    names.remove("josh");
    assertEquals(1, names.size());
    names.remove("vadas");
    assertEquals(0, names.size());
}
 
Example #11
Source File: SumTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_sumX() {
    final Traversal<Vertex, Map<String, Number>> traversal = get_g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_sumX();
    printTraversalForm(traversal);
    assertTrue(traversal.hasNext());
    final Map<String, Number> map = traversal.next();
    assertFalse(traversal.hasNext());
    assertEquals(2, map.size());
    assertEquals(1.0, map.get("ripple"));
    assertEquals(1.0, map.get("lop"));
}
 
Example #12
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_outE_weight_groupCount_unfold_selectXkeysX_unfold() {
    final Traversal<Vertex, Double> traversal = get_g_V_outE_weight_groupCount_unfold_selectXkeysX_unfold();
    printTraversalForm(traversal);
    checkResults(Arrays.asList(0.2, 0.4, 0.5, 1.0), traversal);
}
 
Example #13
Source File: MaxTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_age_fold_maxXlocalX() {
    final Traversal<Vertex, Integer> traversal = get_g_V_age_fold_maxXlocalX();
    printTraversalForm(traversal);
    checkResults(Arrays.asList(35), traversal);
}
 
Example #14
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_asXhereXout_name_selectXhereX() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_asXhereXout_name_selectXhereX();
    printTraversalForm(traversal);
    super.checkResults(new HashMap<Vertex, Long>() {{
        put(convertToVertex(graph, "marko"), 3l);
        put(convertToVertex(graph, "josh"), 2l);
        put(convertToVertex(graph, "peter"), 1l);
    }}, traversal);
}
 
Example #15
Source File: StarGraphTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_USER_SUPPLIED_IDS)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexPropertyFeatures.FEATURE_USER_SUPPLIED_IDS)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_USER_SUPPLIED_IDS)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY)
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldCopyFromGraphAToGraphB() throws Exception {
    final List<StarGraph> starGraphs = IteratorUtils.stream(graph.vertices()).map(StarGraph::of).collect(Collectors.toList());

    // via vertices and then edges
    final Configuration g1Configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), null);
    Graph g1 = graphProvider.openTestGraph(g1Configuration);
    starGraphs.stream().map(StarGraph::getStarVertex).forEach(vertex -> vertex.attach(Attachable.Method.getOrCreate(g1)));
    starGraphs.stream().forEach(starGraph -> starGraph.edges().forEachRemaining(edge -> ((Attachable<Edge>) edge).attach(Attachable.Method.getOrCreate(g1))));
    assertEquals(IteratorUtils.count(graph.vertices()), IteratorUtils.count(g1.vertices()));
    assertEquals(IteratorUtils.count(graph.edges()), IteratorUtils.count(g1.edges()));
    graph.vertices().forEachRemaining(vertex -> TestHelper.validateVertexEquality(vertex, g1.vertices(vertex.id()).next(), true));
    graphProvider.clear(g1, g1Configuration);

    // via edges only
    final Configuration g2Configuration = graphProvider.newGraphConfiguration("readGraph", this.getClass(), name.getMethodName(), null);
    final Graph g2 = graphProvider.openTestGraph(g2Configuration);
    starGraphs.stream().forEach(starGraph -> starGraph.edges().forEachRemaining(edge -> ((Attachable<Edge>) edge).attach(Attachable.Method.getOrCreate(g2))));
    assertEquals(IteratorUtils.count(graph.vertices()), IteratorUtils.count(g2.vertices()));
    assertEquals(IteratorUtils.count(graph.edges()), IteratorUtils.count(g2.edges()));
    // TODO: you can't get adjacent labels -- graph.vertices().forEachRemaining(vertex -> TestHelper.validateVertexEquality(vertex, g1.vertices(vertex.id()).next(), true));
    graphProvider.clear(g2, g2Configuration);
}
 
Example #16
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_selectXlast_a_bX() {
    final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_selectXlast_a_bX();
    printTraversalForm(traversal);
    assertEquals(Collections.emptyList(), traversal.toList());
}
 
Example #17
Source File: ConnectedComponentTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_connectedComponent_hasXcomponentX() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_connectedComponent_hasXcomponentX();
    printTraversalForm(traversal);
    assertEquals(6, IteratorUtils.count(traversal));
}
 
Example #18
Source File: CoalesceTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_outXcreatedX_order_byXnameX_coalesceXname_constantXxXX() {
    final Traversal<Vertex, String> traversal = get_g_V_outXcreatedX_order_byXnameX_coalesceXname_constantXxXX();
    printTraversalForm(traversal);
    checkResults(Arrays.asList("lop", "lop", "lop", "ripple"), traversal);
}
 
Example #19
Source File: DedupTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_both_name_order_byXa_bX_dedup_value() {
    final Traversal<Vertex, String> traversal = get_g_V_both_name_order_byXa_bX_dedup_value();
    printTraversalForm(traversal);
    final List<String> names = traversal.toList();
    assertEquals(6, names.size());
    assertEquals("josh", names.get(0));
    assertEquals("lop", names.get(1));
    assertEquals("marko", names.get(2));
    assertEquals("peter", names.get(3));
    assertEquals("ripple", names.get(4));
    assertEquals("vadas", names.get(5));
    assertFalse(traversal.hasNext());
}
 
Example #20
Source File: GraphComputerTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void shouldNotAllowWithNoVertexProgramNorMapReducers() throws Exception {
    try {
        graphProvider.getGraphComputer(graph).submit().get();
        fail("Should throw an IllegalStateException when there is no vertex program nor map reducers");
    } catch (Exception ex) {
        validateException(GraphComputer.Exceptions.computerHasNoVertexProgramNorMapReducers(), ex);
    }
}
 
Example #21
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_name_order_asXbX_selectXa_bX_byXnameX_by_XitX() {
    final Traversal<Vertex, Map<String, String>> traversal = get_g_V_asXaX_name_order_asXbX_selectXa_bX_byXnameX_by_XitX();
    printTraversalForm(traversal);
    final List<Map<String, String>> expected = makeMapList(2,
            "a", "marko", "b", "marko",
            "a", "vadas", "b", "vadas",
            "a", "josh", "b", "josh",
            "a", "ripple", "b", "ripple",
            "a", "lop", "b", "lop",
            "a", "peter", "b", "peter");
    checkResults(expected, traversal);
}
 
Example #22
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_outE_weight_groupCount_unfold_selectXvaluesX_unfold() {
    final Traversal<Vertex, Long> traversal = get_g_V_outE_weight_groupCount_unfold_selectXvaluesX_unfold();
    printTraversalForm(traversal);
    checkResults(Arrays.asList(1l, 1l, 2l, 2l), traversal);
}
 
Example #23
Source File: AndTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_outXknowsX_and_outXcreatedX_inXcreatedX_asXaX_name() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_asXaX_outXknowsX_and_outXcreatedX_inXcreatedX_asXaX_name();
    printTraversalForm(traversal);
    checkResults(Collections.singletonList(convertToVertex(graph, "marko")), traversal);
}
 
Example #24
Source File: RepeatTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_timesX2X_repeatXoutX_name() {
    final Traversal<Vertex, String> traversal = get_g_VX1X_timesX2X_repeatXoutX_name(convertToVertexId("marko"));
    printTraversalForm(traversal);
    checkResults(Arrays.asList("lop", "ripple"), traversal);
}
 
Example #25
Source File: RangeTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_outXknowsX_outXcreatedX_rangeX0_1X() {
    final Traversal<Vertex, Vertex> traversal = get_g_VX1X_outXknowsX_outXcreatedX_rangeX0_1X(convertToVertexId("marko"));
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        final String name = traversal.next().value("name");
        assertTrue(name.equals("lop") || name.equals("ripple"));
    }
    assertEquals(1, counter);
}
 
Example #26
Source File: WhereTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX() {
    final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX();
    printTraversalForm(traversal);
    checkResults(makeMapList(2,
            "a", convertToVertex(graph, "marko"), "b", convertToVertex(graph, "josh"),
            "a", convertToVertex(graph, "marko"), "b", convertToVertex(graph, "vadas")), traversal);
}
 
Example #27
Source File: SackTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack() {
    final Traversal<Vertex, BigDecimal> traversal = get_g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack();
    printTraversalForm(traversal);
    final BigDecimal half = BigDecimal.ONE.divide(BigDecimal.ONE.add(BigDecimal.ONE));
    assertTrue(traversal.hasNext());
    assertEquals(half, traversal.next());
    assertTrue(traversal.hasNext());
    assertEquals(half, traversal.next());
    assertFalse(traversal.hasNext());
}
 
Example #28
Source File: VertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_to_XOUT_knowsX() {
    final Traversal<Vertex, Vertex> traversal = get_g_VX1X_to_XOUT_knowsX(convertToVertexId("marko"));
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        final Vertex vertex = traversal.next();
        final String name = vertex.value("name");
        assertTrue(name.equals("vadas") || name.equals("josh"));
    }
    assertEquals(2, counter);
    assertFalse(traversal.hasNext());
}
 
Example #29
Source File: MathTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_outXknowsX_asXbX_mathXa_plus_bX_byXageX() {
    final Traversal<Vertex, Double> traversal = get_g_V_asXaX_outXknowsX_asXbX_mathXa_plus_bX_byXageX();
    printTraversalForm(traversal);
    checkResults(Arrays.asList(56.0d, 61.0d), traversal);
}
 
Example #30
Source File: FileSystemStorageCheck.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldNotHaveResidualDataInStorage() throws Exception {
    // Make sure Spark is shut down before deleting its files and directories,
    // which are locked under Windows and fail the tests. See FileSystemStorageCheck
    graph.configuration().setProperty(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false);

    final Storage storage = FileSystemStorage.open(ConfUtil.makeHadoopConfiguration(graph.configuration()));
    final String outputLocation = graph.configuration().getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION);
    super.checkResidualDataInStorage(storage, outputLocation);
}