@Test
    public void shouldBeVerified() {
        final String repr = traversal.getGremlinLang().getGremlin();
        final Traversal copy = copyAndConfigureTraversal(traversal);

        if (legalTraversal) {
            copy.asAdmin().applyStrategies();

            // try to also apply strategies with iterate() so that a DiscardStep is added - for consistency sake we want
            // to be able to run a profile and get no result back with this.
            final Traversal forIteration = copyAndConfigureTraversal(traversal);
            forIteration.iterate();
        } else {
            try {
                copy.asAdmin().applyStrategies();
                fail("The strategy should not allow traversal: " + repr);
            } catch (Exception ise) {
                assertThat(ise, instanceOf(VerificationException.class));
            }
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java