@Test
    public void doTest() {
        final String repr = original.getGremlinLang().getGremlin("__");
        final TraversalStrategies strategiesWithLazy = new DefaultTraversalStrategies();
        strategiesWithLazy.addStrategies(RepeatUnrollStrategy.instance());
        Traversal.Admin<?, ?> clonedOriginal = this.original.clone();

        // adding LazyBarrierStrategy as RepeatUnrollStrategy adds barriers and the existence of this strategy
        // triggers those additions. if they are not there they will not be present and most of these assertions
        // assume this strategy present
        strategiesWithLazy.addStrategies(LazyBarrierStrategy.instance());
        for (final TraversalStrategy<?> strategy : this.otherStrategies) {
            strategiesWithLazy.addStrategies(strategy);
        }
        clonedOriginal.setStrategies(strategiesWithLazy);
        clonedOriginal.applyStrategies();
        assertEquals("With LazyBarrierStrategy: " + repr, this.optimized, clonedOriginal);

        final TraversalStrategies strategiesWithoutLazy = new DefaultTraversalStrategies();
        strategiesWithoutLazy.addStrategies(RepeatUnrollStrategy.instance());
        for (final TraversalStrategy<?> strategy : this.otherStrategies) {
            strategiesWithoutLazy.addStrategies(strategy);
        }
        clonedOriginal = this.original.clone();
        clonedOriginal.setStrategies(strategiesWithoutLazy);
        clonedOriginal.applyStrategies();
        final Traversal.Admin<?, ?> optimizedWithoutBarriers = this.optimized.asAdmin().clone();

        // remove all the barriers as LazyBarrierStrategy is not present and therefore RepeatUnrollStrategy should
        // not add any
        TraversalHelper.getStepsOfAssignableClassRecursively(NoOpBarrierStep.class, optimizedWithoutBarriers).forEach(s -> {
            TraversalHelper.copyLabels(s, s.getPreviousStep(), true);
            s.getTraversal().removeStep(s);
        });
        assertEquals("Without LazyBarrierStrategy: " + repr, optimizedWithoutBarriers, clonedOriginal);

    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategyTest.java