org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine. 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: AbstractGremlinSuite.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
private boolean checkGraphProviderDescriptorForComputer(final Graph.OptOut optOut) {
    // immediately include the ignore if this is a standard tests suite (i.e. not computer)
    // or if the OptOut doesn't specify any computers to filter
    if (traversalEngineType == TraversalEngine.Type.STANDARD
            || optOut.computers().length == 0) {
        return true;
    }
    // can assume that that GraphProvider.Descriptor is not null at this point.  a test should
    // only opt out if it matches the expected computer
    return Stream.of(optOut.computers()).map(c -> {
        try {
            return Class.forName(c);
        } catch (ClassNotFoundException e) {
            return Object.class;
        }
    }).filter(c -> !c.equals(Object.class)).anyMatch(c -> c == graphProviderDescriptor.get().computer());
}
 
Example #2
Source File: AbstractGremlinSuite.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
private void registerOptOuts(final Class<?> classWithOptOuts,
                             final Optional<GraphProvider.Descriptor> graphProviderDescriptor,
                             final TraversalEngine.Type traversalEngineType) throws InitializationError {
    // don't get why getAnnotationsByType() refuses to pick up OptOuts on the superclass. doing it manually and
    // only for the immediate superclass for now
    final List<Graph.OptOut> optOuts = getAllOptOuts(classWithOptOuts);

    if (!optOuts.isEmpty()) {
        // validate annotation - test class and reason must be set
        if (!optOuts.stream().allMatch(ignore -> ignore.test() != null && ignore.reason() != null && !ignore.reason().isEmpty()))
            throw new InitializationError("Check @IgnoreTest annotations - all must have a 'test' and 'reason' set");

        try {
            final Graph.OptOut[] oos = new Graph.OptOut[optOuts.size()];
            optOuts.toArray(oos);
            filter(new OptOutTestFilter(oos, graphProviderDescriptor, traversalEngineType));
        } catch (NoTestsRemainException ex) {
            throw new InitializationError(ex);
        }
    }
}
 
Example #3
Source File: MapTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_withPath_V_asXaX_out_mapXa_nameX() {
    int marko = 0;
    int peter = 0;
    int josh = 0;
    int other = 0;

    final Traversal<Vertex, String> traversal = get_g_withPath_V_asXaX_out_mapXa_nameX();
    printTraversalForm(traversal);
    while (traversal.hasNext()) {
        final String name = traversal.next();
        if (name.equals("marko")) marko++;
        else if (name.equals("peter")) peter++;
        else if (name.equals("josh")) josh++;
        else other++;
    }
    assertEquals(marko, 3);
    assertEquals(josh, 2);
    assertEquals(peter, 1);
    assertEquals(other, 0);
}
 
Example #4
Source File: ProcessBasicSuite.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
public ProcessBasicSuite(final Class<?> klass,
                         final RunnerBuilder builder)
                         throws InitializationError {
    super(klass, builder, allTests, testsToEnforce, true,
          TraversalEngine.Type.STANDARD);
    RegisterUtil.registerBackends();
}
 
Example #5
Source File: NativeNeo4jSuite.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public NativeNeo4jSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder,
            new Class<?>[]{
                    NativeNeo4jStructureCheck.class,
                    NativeNeo4jIndexCheck.class,
                    NativeNeo4jCypherCheck.class,
            }, new Class<?>[]{
                    NativeNeo4jStructureCheck.class,
                    NativeNeo4jIndexCheck.class,
                    NativeNeo4jCypherCheck.class
            },
            false,
            TraversalEngine.Type.STANDARD);
}
 
Example #6
Source File: AbstractGremlinSuite.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public OptOutTestFilter(final Graph.OptOut[] optOuts,
                        final Optional<GraphProvider.Descriptor> graphProviderDescriptor,
                        final TraversalEngine.Type traversalEngineType) {
    this.graphProviderDescriptor = graphProviderDescriptor;
    this.traversalEngineType = traversalEngineType;

    // split the tests to filter into two groups - true represents those that should ignore a whole
    final Map<Boolean, List<Graph.OptOut>> split = Arrays.stream(optOuts)
            .filter(this::checkGraphProviderDescriptorForComputer)
            .collect(Collectors.groupingBy(optOut -> optOut.method().equals("*")));

    final List<Graph.OptOut> optOutsOfIndividualTests = split.getOrDefault(Boolean.FALSE, Collections.emptyList());
    individualSpecificTestsToIgnore = optOutsOfIndividualTests.stream()
            .filter(ignoreTest -> !ignoreTest.method().equals("*"))
            .filter(allowAbstractMethod(false))
            .<Pair>map(ignoreTest -> Pair.with(ignoreTest.test(), ignoreTest.specific().isEmpty() ? ignoreTest.method() : String.format("%s[%s]", ignoreTest.method(), ignoreTest.specific())))
            .<Description>map(p -> Description.createTestDescription(p.getValue0().toString(), p.getValue1().toString()))
            .collect(Collectors.toList());

    testGroupToIgnore = optOutsOfIndividualTests.stream()
            .filter(ignoreTest -> !ignoreTest.method().equals("*"))
            .filter(allowAbstractMethod(true))
            .<Pair>map(ignoreTest -> Pair.with(ignoreTest.test(), ignoreTest.specific().isEmpty() ? ignoreTest.method() : String.format("%s[%s]", ignoreTest.method(), ignoreTest.specific())))
            .<Description>map(p -> Description.createTestDescription(p.getValue0().toString(), p.getValue1().toString()))
            .collect(Collectors.toList());

    entireTestCaseToIgnore = split.getOrDefault(Boolean.TRUE, Collections.emptyList());
}
 
Example #7
Source File: AbstractGremlinSuite.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private Optional<GraphProvider.Descriptor> getGraphProviderDescriptor(final TraversalEngine.Type traversalEngineType,
                                                                      final Class<? extends GraphProvider> klass) throws InitializationError {
    final GraphProvider.Descriptor descriptorAnnotation = klass.getAnnotation(GraphProvider.Descriptor.class);
    if (traversalEngineType == TraversalEngine.Type.COMPUTER) {
        // can't be null if this is graph computer business
        if (null == descriptorAnnotation)
            throw new InitializationError(String.format("For 'computer' tests, '%s' must have a GraphProvider.Descriptor annotation", klass.getName()));
    }

    return Optional.ofNullable(descriptorAnnotation);
}
 
Example #8
Source File: AbstractGremlinSuite.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a Gremlin Test Suite implementation.
 *
 * @param klass               Required for JUnit Suite construction
 * @param builder             Required for JUnit Suite construction
 * @param testsToExecute      The list of tests to execute
 * @param testsToEnforce      The list of tests to "enforce" such that a check is made to ensure that in this list,
 *                            there exists an implementation in the testsToExecute (use {@code null} for no
 *                            enforcement).
 * @param gremlinFlavorSuite  Ignore validation of {@link Graph.OptIn} annotations which is typically reserved for structure tests
 * @param traversalEngineType The {@link TraversalEngine.Type} to enforce on this suite
 */
public AbstractGremlinSuite(final Class<?> klass, final RunnerBuilder builder, final Class<?>[] testsToExecute,
                            final Class<?>[] testsToEnforce, final boolean gremlinFlavorSuite,
                            final TraversalEngine.Type traversalEngineType) throws InitializationError {
    super(builder, klass, enforce(testsToExecute, testsToEnforce));

    this.gremlinFlavorSuite = gremlinFlavorSuite;

    // figures out what the implementer assigned as the GraphProvider class and make it available to tests.
    // the klass is the Suite that implements this suite (e.g. GroovyTinkerGraphProcessStandardTest).
    // this class should be annotated with GraphProviderClass.  Failure to do so will toss an InitializationError
    final Pair<Class<? extends GraphProvider>, Class<? extends Graph>> pair = getGraphProviderClass(klass);

    // the GraphProvider.Descriptor is only needed right now if the test if for a computer engine - an
    // exception is thrown if it isn't present.
    final Optional<GraphProvider.Descriptor> graphProviderDescriptor = getGraphProviderDescriptor(traversalEngineType, pair.getValue0());

    // validate public acknowledgement of the test suite and filter out tests ignored by the implementation
    validateOptInToSuite(pair.getValue1());
    validateOptInAndOutAnnotations(pair.getValue0());
    validateOptInAndOutAnnotations(pair.getValue1());

    registerOptOuts(pair.getValue0(), graphProviderDescriptor, traversalEngineType);
    registerOptOuts(pair.getValue1(), graphProviderDescriptor, traversalEngineType);

    try {
        final GraphProvider graphProvider = pair.getValue0().newInstance();
        GraphManager.setGraphProvider(graphProvider);
        GraphManager.setTraversalEngineType(traversalEngineType);
    } catch (Exception ex) {
        throw new InitializationError(ex);
    }
}
 
Example #9
Source File: ComplexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER) // no mid-traversal V() in computer mode + star-graph limitations
public void coworkerSummaryOLTP() {
    final Traversal<Vertex, Map<String, Map<String, Map<String, Object>>>> traversal = getCoworkerSummaryOLTP();
    printTraversalForm(traversal);
    assertTrue(traversal.hasNext());
    checkCoworkerSummary(traversal.next());
    assertFalse(traversal.hasNext());
}
 
Example #10
Source File: ExplainTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_outE_identity_inV_explain() {
    final TraversalExplanation explanation = get_g_V_outE_identity_inV_explain();
    if (explanation.getStrategyTraversals().stream().map(Pair::getValue0).filter(s -> s instanceof IdentityRemovalStrategy || s instanceof IncidentToAdjacentStrategy).count() == 2) {
        printTraversalForm(explanation.getOriginalTraversal());
        boolean beforeIncident = true;
        boolean beforeIdentity = true;
        for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : explanation.getStrategyTraversals()) {
            if (pair.getValue0().getClass().equals(IncidentToAdjacentStrategy.class))
                beforeIncident = false;
            if (pair.getValue0().getClass().equals(IdentityRemovalStrategy.class))
                beforeIdentity = false;

            if (beforeIdentity)
                assertEquals(1, TraversalHelper.getStepsOfClass(IdentityStep.class, pair.getValue1()).size());

            if (beforeIncident)
                assertEquals(1, TraversalHelper.getStepsOfClass(EdgeVertexStep.class, pair.getValue1()).size());

            if (!beforeIdentity)
                assertEquals(0, TraversalHelper.getStepsOfClass(IdentityStep.class, pair.getValue1()).size());

            if (!beforeIncident)
                assertEquals(0, TraversalHelper.getStepsOfClass(EdgeVertexStep.class, pair.getValue1()).size());
        }
        assertFalse(beforeIncident);
    }
}
 
Example #11
Source File: SideEffectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_VX1X_out_sideEffectXincr_cX_name() {
    final Traversal<Vertex, String> traversal = get_g_VX1X_out_sideEffectXincr_cX_name(convertToVertexId("marko"));
    printTraversalForm(traversal);
    assert_g_v1_out_sideEffectXincr_cX_valueXnameX(traversal);
    assertEquals(new Integer(3), traversal.asAdmin().getSideEffects().<List<Integer>>get("c").get(0));
    checkSideEffects(traversal.asAdmin().getSideEffects(), "c", ArrayList.class);
}
 
Example #12
Source File: SideEffectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_VX1X_sideEffectXstore_aX_name() {
    final Traversal<Vertex, String> traversal = get_g_VX1X_sideEffectXstore_aX_name(convertToVertexId("marko"));
    printTraversalForm(traversal);
    assertEquals(traversal.next(), "marko");
    assertFalse(traversal.hasNext());
    assertEquals(convertToVertexId("marko"), traversal.asAdmin().getSideEffects().<List<Vertex>>get("a").get(0).id());
    checkSideEffects(traversal.asAdmin().getSideEffects(), "a", ArrayList.class);
}
 
Example #13
Source File: ProfileTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.STANDARD)
public void g_V_hasLabelXpersonX_pageRank_withXpropertyName_rankX_withXedges_bothEX_rank_profile() {
    final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_hasLabelXpersonX_pageRank_withXpropertyName_rankX_withXedges_bothEX_rank_profile();
    //printTraversalForm(traversal);
    try {
        traversal.iterate();
        fail("Should have tossed an exception because multi-OLAP is unsolvable");
    } catch (Exception ex) {
        assertTrue(ex instanceof VerificationException || ExceptionUtils.getRootCause(ex) instanceof VerificationException);
    }
}
 
Example #14
Source File: ProfileTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX();
    printTraversalForm(traversal);
    traversal.iterate();

    // This assertion is really only meant for tinkergraph
    if (graph.getClass().getSimpleName().equals("TinkerGraph"))
        assertEquals("There should be 7 steps in this traversal (counting injected profile steps).", 7, traversal.asAdmin().getSteps().size());

    final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().get(METRICS_KEY);
    validate_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile(traversalMetrics);
}
 
Example #15
Source File: ProfileTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile() {
    final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile();
    printTraversalForm(traversal);

    // This assertion is really only meant for tinkergraph
    if (graph.getClass().getSimpleName().equals("TinkerGraph"))
        assertEquals("There should be 8 steps in this traversal (counting injected profile steps).", 8, traversal.asAdmin().getSteps().size());

    final TraversalMetrics traversalMetrics = traversal.next();
    validate_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile(traversalMetrics);
}
 
Example #16
Source File: OrderTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@IgnoreEngine(TraversalEngine.Type.STANDARD) // validating the internal sort/limit works in GraphComputer
@LoadGraphWith(MODERN)
public void g_V_both_hasLabelXpersonX_order_byXage_descX_name() {
    final Traversal<Vertex, String> traversal = get_g_V_both_hasLabelXpersonX_order_byXage_descX_name();
    traversal.asAdmin().applyStrategies();
    if (!TraversalHelper.getFirstStepOfAssignableClass(OrderGlobalStep.class, traversal.asAdmin()).isPresent())
        return; // total hack to avoid providers that don't compile to OrderGlobalStep
    TraversalHelper.getFirstStepOfAssignableClass(OrderGlobalStep.class, traversal.asAdmin()).get().setLimit(1);
    printTraversalForm(traversal);
    final List<String> results = traversal.toList();
    assertTrue(results.size() < 8);
    assertFalse(traversal.hasNext());
}
 
Example #17
Source File: MapTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_withPath_V_asXaX_out_out_mapXa_name_it_nameX() {
    final Traversal<Vertex, String> traversal = get_g_withPath_V_asXaX_out_out_mapXa_name_it_nameX();
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        final String doubleName = traversal.next();
        assertTrue("markoripple".equals(doubleName) || "markolop".equals(doubleName));
    }
    assertEquals(2, counter);
    assertFalse(traversal.hasNext());
}
 
Example #18
Source File: VertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_VX1_2_3_4X_name() {
    final Object vLop = convertToVertexId("lop");
    g.V(vLop).drop().iterate();
    final Traversal<Vertex, String> traversal = get_g_VX1_2_3_4X_name(convertToVertexId("marko"), convertToVertexId("vadas"), vLop, convertToVertexId("josh"));
    printTraversalForm(traversal);
    checkResults(Arrays.asList("marko", "vadas", "josh"), traversal);
    assertFalse(traversal.hasNext());
}
 
Example #19
Source File: StructureBasicSuite.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
public StructureBasicSuite(final Class<?> klass,
                           final RunnerBuilder builder)
                           throws InitializationError,
                                  ConfigurationException {
    super(klass, builder, allTests, null, true,
          TraversalEngine.Type.STANDARD);

    RegisterUtil.registerBackends();
}
 
Example #20
Source File: ProcessBasicSuite.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
public ProcessBasicSuite(final Class<?> klass,
                         final RunnerBuilder builder,
                         final Class<?>[] testsToExecute)
                         throws InitializationError {
    super(klass, builder, testsToExecute, testsToEnforce, true,
          TraversalEngine.Type.STANDARD);
    RegisterUtil.registerBackends();
}
 
Example #21
Source File: TitanStrategySuite.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public TitanStrategySuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {

        super(klass, builder,
                new Class<?>[]{
                        TitanGraphStepStrategyTest.class
                }, new Class<?>[]{
                        TitanGraphStepStrategyTest.class
                },
                false,
                TraversalEngine.Type.STANDARD);
    }
 
Example #22
Source File: CustomSuite.java    From hgraphdb with Apache License 2.0 5 votes vote down vote up
public CustomSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder,
            new Class<?>[]{
                    CustomTest.class,
            },
            null,
            false,
            TraversalEngine.Type.STANDARD);
}
 
Example #23
Source File: ArangoDBTestSuite.java    From arangodb-tinkerpop-provider with Apache License 2.0 4 votes vote down vote up
public ArangoDBTestSuite(
	Class<?> klass,
	RunnerBuilder builder)
	throws InitializationError {
	super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
}
 
Example #24
Source File: SparkGremlinSuite.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public SparkGremlinSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder, new Class<?>[]{SparkContextStorageCheck.class, SparkIoRegistryCheck.class}, new Class<?>[]{SparkContextStorageCheck.class, SparkIoRegistryCheck.class}, true, TraversalEngine.Type.COMPUTER);
}
 
Example #25
Source File: HadoopGremlinSuite.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public HadoopGremlinSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder, new Class<?>[]{FileSystemStorageCheck.class}, new Class<?>[]{FileSystemStorageCheck.class}, true, TraversalEngine.Type.COMPUTER);
}
 
Example #26
Source File: BitsyGraphStructureTestSuite.java    From bitsy with Apache License 2.0 4 votes vote down vote up
public BitsyGraphStructureTestSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
}
 
Example #27
Source File: StructureStandardSuite.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public StructureStandardSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
}
 
Example #28
Source File: StructureBasicSuite.java    From hgraphdb with Apache License 2.0 4 votes vote down vote up
public StructureBasicSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
    super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
}
 
Example #29
Source File: AbstractGremlinProcessTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
/**
 * Determines if this test suite has "computer" requirements.
 */
protected boolean hasGraphComputerRequirement() {
    // do the negation of STANDARD as we expect a future type of REASONING that would infer COMPUTER support
    return !GraphManager.getTraversalEngineType().equals(TraversalEngine.Type.STANDARD);
}
 
Example #30
Source File: EarlyLimitStrategyProcessTest.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Test
@LoadGraphWith(GRATEFUL)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void shouldHandleRangeSteps() throws Exception {

    final GraphTraversal<Vertex, Map<String, List<String>>> t =
            g.V().has("artist", "name", "Bob_Dylan")
                    .in("sungBy")
                    .order()
                        .by("performances", Order.desc).as("a")
                    .repeat(__.out("followedBy")
                                .order()
                                    .by("performances", Order.desc)
                                .simplePath()
                                    .from("a"))
                        .until(__.out("writtenBy").has("name", "Johnny_Cash"))
                    .limit(1).as("b")
                    .repeat(__.out("followedBy")
                                .order()
                                    .by("performances", Order.desc).as("c")
                                .simplePath()
                                    .from("b")
                                    .to("c"))
                        .until(__.out("sungBy").has("name", "Grateful_Dead"))
                    .limit(5).as("d")
                    .path()
                        .from("a")
                    .limit(1).as("e")
                    .unfold().
                    <List<String>>project("song", "artists")
                        .by("name")
                        .by(__.coalesce(
                                __.out("sungBy", "writtenBy").dedup().values("name"),
                                __.constant("Unknown"))
                                .fold());

    final GraphTraversal pt = t.asAdmin().clone().profile();
    final List<Map<String, List<String>>> result = t.toList();
    final TraversalMetrics metrics = (TraversalMetrics) pt.next();

    assertEquals(6, result.size());

    assumeTrue("The following assertions apply to TinkerGraph only as provider strategies can alter the " +
                    "steps to not comply with expectations", graph.getClass().getSimpleName().equals("TinkerGraph"));

    if (t.asAdmin().getStrategies().getStrategy(EarlyLimitStrategy.class).isPresent()) {
        assertEquals(10, metrics.getMetrics().size());
        assertTrue(metrics.getMetrics(5).getName().endsWith("@[d]"));
        assertEquals("RangeGlobalStep(0,1)", metrics.getMetrics(6).getName());
        assertEquals("PathStep@[e]", metrics.getMetrics(7).getName());
        assertTrue(metrics.getMetrics(7).getCounts().values().stream().noneMatch(x -> x != 1L));
    } else {
        assertEquals(11, metrics.getMetrics().size());
        assertEquals("RangeGlobalStep(0,5)@[d]", metrics.getMetrics(6).getName());
        assertEquals("PathStep", metrics.getMetrics(7).getName());
        assertEquals("RangeGlobalStep(0,1)@[e]", metrics.getMetrics(8).getName());
        assertTrue(metrics.getMetrics(7).getCounts().values().stream().allMatch(x -> x != 1L));
    }
}