@Test
    public void shouldWordWrapCorrectly() {
        GraphTraversal<?, ?> traversal = __.V().out().out();
        String toString = traversal.explain().prettyPrint();
        assertFalse(toString.contains("VertexStep(OUT,vertex),\n"));
        //System.out.println(toString);
        ///
        traversal = __.V().out().out().out().out();
        toString = traversal.explain().prettyPrint();
        assertTrue(toString.contains("VertexStep(OUT,vertex),"));
        //System.out.println(toString);
        ///
        for (int i = 0; i < 30; i++) {
            traversal = __.V();
            for (int j = 0; j < i; j++) {
                traversal.out();
            }
            traversal.asAdmin().setStrategies(TraversalStrategies.GlobalCache.getStrategies(Graph.class));
            toString = traversal.explain().prettyPrint();
            if (i < 3)
                assertFalse(toString.contains("VertexStep(OUT,vertex),\n"));
            else {
                assertTrue(Stream.of(toString.split("\n"))
                        .filter(s -> s.startsWith(" "))
                        .map(String::trim)
                        .filter(s -> Character.isLowerCase(s.charAt(0)))
                        .findAny()
                        .isPresent()); // all indented word wraps should start with steps
                assertTrue(toString.contains("vertex"));
            }
            for (int j = 80; j < 200; j++) {
                for (final String line : traversal.explain().prettyPrint(j).split("\n")) {
                    assertTrue(line.length() <= j);
                }
            }
            // System.out.println(toString);
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java