@Test
    public void shouldApplyStrategiesCorrectly() {
        Traversal.Admin<?, ?> traversal = __.out().count().asAdmin();
        traversal.setStrategies(TraversalStrategies.GlobalCache.getStrategies(Graph.class));
        int found = 0;
        for (final String line : traversal.explain().toString().split("\n")) {
            if (line.contains("AdjacentToIncidentStrategy") && line.contains("[VertexStep(OUT,edge)"))
                found++;
        }
        assertEquals(1, found);
        ///
        traversal = __.out().group().by(__.in().count()).asAdmin();
        traversal.setStrategies(TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone());
        found = 0;
        for (final String line : traversal.explain().toString().split("\n")) {
            if (line.contains("AdjacentToIncidentStrategy") && line.contains("[VertexStep(IN,edge)"))
                found++;
        }
        assertEquals(1, found);
        ///
        traversal = __.outE().inV().group().by(__.inE().outV().groupCount().by(__.both().count().is(P.gt(2)))).asAdmin();
        traversal.setStrategies(TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().removeStrategies(ProductiveByStrategy.class));
        // System.out.println(traversal.explain());
        found = 0;
        for (final String line : traversal.explain().toString().split("]\n")) { // need to split cause of word wrap
            //System.out.println(line + "\n\n");
            if (line.contains("IncidentToAdjacentStrategy") && line.contains("[VertexStep(IN,vertex)"))
                found++;
            if (line.contains("IncidentToAdjacentStrategy") && line.contains("[VertexStep(OUT,vertex)"))
                found++;
            if (line.contains("AdjacentToIncidentStrategy") && line.contains("[VertexStep(BOTH,edge)"))
                found++;
            if (line.contains("CountStrategy") && line.contains("RangeGlobalStep(0,3)"))
                found++;
        }
        assertEquals(4, found);
        //
        //System.out.println(traversal.explain().prettyPrint(160));
        found = 0;
        for (final String line : traversal.explain().prettyPrint(170).split("]\n")) { // need to split cause of word wrap
            if (line.contains("IncidentToAdjacentStrategy") && line.contains("[VertexStep(IN,vertex)"))
                found++;
            if (line.contains("IncidentToAdjacentStrategy") && line.contains("[VertexStep(OUT,vertex)"))
                found++;
            if (line.contains("AdjacentToIncidentStrategy") && line.contains("[VertexStep(BOTH,edge)"))
                found++;
            if (line.contains("CountStrategy") && line.contains("RangeGlobalStep(0,3)"))
                found++;
        }
        assertEquals(4, found);
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java