private void assertTraversal(final Traversal t, final boolean expectMutatingStep) {
        try {
            // not sure why i need a special hook here for RemoteGraph. It only triggers these exceptions on a
            // call to hasNext() and not on applyStrategies()
            if (graph instanceof RemoteGraph)
                t.hasNext();
            else
                t.asAdmin().applyStrategies();

            if (expectMutatingStep) fail("The strategy should have found a mutating step.");
        } catch (final Exception ise) {
            if (!expectMutatingStep)
                fail("The traversal should not have failed as there is no mutating step.");
            else {
                // TraversalVerificationStrategy fails before this as mutating operations are not allowed in OLAP
                if (!(ise instanceof VerificationException))
                    assertThat(ise.getMessage(), containsString("The provided traversal has a mutating step and thus is not read only"));
            }
        }
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/ReadOnlyStrategyProcessTest.java