You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/08/22 20:40:02 UTC
[17/48] tinkerpop git commit: TINKERPOP-1405 Fixed a small bug in
StandardVerificationStrategy that caused verification to fail when withPath
was used in conjunction with ProfileStep.
TINKERPOP-1405 Fixed a small bug in StandardVerificationStrategy that caused verification to fail when withPath was used in conjunction with ProfileStep.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d7ae2800
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d7ae2800
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d7ae2800
Branch: refs/heads/TINKERPOP-1278
Commit: d7ae28007c409995a75012d84611151a308c0ded
Parents: 9542419
Author: Ted Wilmes <tw...@gmail.com>
Authored: Tue Aug 16 10:00:15 2016 -0500
Committer: Ted Wilmes <tw...@gmail.com>
Committed: Tue Aug 16 10:00:15 2016 -0500
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../StandardVerificationStrategy.java | 15 +++++--
.../StandardVerificationStrategyTest.java | 41 +++++++++++++++-----
3 files changed, 43 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d7ae2800/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index bff6907..ac364b1 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -33,6 +33,7 @@ TinkerPop 3.2.2 (NOT OFFICIALLY RELEASED YET)
* Added methods to retrieve `Cluster` settings in `gremlin-driver`.
* Fixed a severe bug in `SubgraphStrategy`.
* Deprecated `SubgraphStrategy.Builder.vertexCriterion()/edgeCriterion()` in favor of `vertices()/edges()`.
+* Fixed a small bug in `StandardVerificationStrategy` that caused verification to fail when `withPath` was used in conjunction with `ProfileStep`.
[[release-3-2-1]]
TinkerPop 3.2.1 (Release Date: July 18, 2016)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d7ae2800/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
index 4fc7da2..95aa2e7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategy.java
@@ -19,12 +19,14 @@
package org.apache.tinkerpop.gremlin.process.traversal.strategy.verification;
import org.apache.tinkerpop.gremlin.process.computer.traversal.step.VertexComputing;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.RequirementsStep;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
@@ -53,11 +55,16 @@ public final class StandardVerificationStrategy extends AbstractTraversalStrateg
throw new VerificationException("The parent of a reducing barrier can not be repeat()-step: " + step, traversal);
});
- // The ProfileSideEffectStep must be the last step or the 2nd last step when accompanied by the cap step.
+ // The ProfileSideEffectStep must be the last step, 2nd last step when accompanied by the cap step,
+ // or 3rd to last when the traversal ends with a RequirementsStep.
+ final Step<?,?> endStep = traversal.asAdmin().getEndStep();
if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) &&
- !(traversal.asAdmin().getEndStep() instanceof ProfileSideEffectStep) &&
- !(traversal.asAdmin().getEndStep() instanceof SideEffectCapStep && traversal.asAdmin().getEndStep().getPreviousStep() instanceof ProfileSideEffectStep)) {
- throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step.", traversal);
+ !(endStep instanceof ProfileSideEffectStep ||
+ (endStep instanceof SideEffectCapStep && endStep.getPreviousStep() instanceof ProfileSideEffectStep) ||
+ (endStep instanceof RequirementsStep && (
+ endStep.getPreviousStep() instanceof SideEffectCapStep ||
+ endStep.getPreviousStep() instanceof ProfileSideEffectStep)))) {
+ throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step and/or requirements step.", traversal);
}
if (TraversalHelper.getStepsOfClass(ProfileSideEffectStep.class, traversal).size() > 1) {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d7ae2800/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
index 2d80de4..aa64f68 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/verification/StandardVerificationStrategyTest.java
@@ -20,13 +20,17 @@ package org.apache.tinkerpop.gremlin.process.traversal.strategy.verification;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.RequirementsStep;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
+import java.util.Collections;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.__;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.repeat;
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.sum;
@@ -39,11 +43,20 @@ import static org.junit.Assert.fail;
@RunWith(Parameterized.class)
public class StandardVerificationStrategyTest {
+ private static final RequirementsStep emptyRequirementStep = new RequirementsStep<>(null, Collections.EMPTY_SET);
+
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
- {"__.repeat(out().fold().unfold()).times(2)", repeat(out().fold().unfold()).times(2)},
- {"__.repeat(sum()).times(2)", repeat(sum()).times(2)},
+ // traversals that should fail verification
+ {"__.repeat(out().fold().unfold()).times(2)", repeat(out().fold().unfold()).times(2), false},
+ {"__.repeat(sum()).times(2)", repeat(sum()).times(2), false},
+ {"__.repeat(out().count())", repeat(out().count()), false},
+ // traversals that should pass verification
+ {"__.V().profile().requirementsStep()",
+ __.V().profile().asAdmin().addStep(emptyRequirementStep), true},
+ {"__.V().profile('metrics').cap('metrics').requirementsStep()",
+ __.V().profile("metrics").asAdmin().addStep(emptyRequirementStep), true}
});
}
@@ -53,16 +66,24 @@ public class StandardVerificationStrategyTest {
@Parameterized.Parameter(value = 1)
public Traversal traversal;
+ @Parameterized.Parameter(value = 2)
+ public Boolean legalTraversal;
+
@Test
- public void shouldBeVerifiedIllegal() {
- try {
- final TraversalStrategies strategies = new DefaultTraversalStrategies();
- strategies.addStrategies(StandardVerificationStrategy.instance());
- traversal.asAdmin().setStrategies(strategies);
+ public void shouldBeVerified() {
+ final TraversalStrategies strategies = new DefaultTraversalStrategies();
+ strategies.addStrategies(StandardVerificationStrategy.instance());
+ traversal.asAdmin().setStrategies(strategies);
+
+ if (legalTraversal) {
traversal.asAdmin().applyStrategies();
- fail("The strategy should not allow traversal: " + this.traversal);
- } catch (IllegalStateException ise) {
- assertTrue(true);
+ } else {
+ try {
+ traversal.asAdmin().applyStrategies();
+ fail("The strategy should not allow traversal: " + this.traversal);
+ } catch (IllegalStateException ise) {
+ assertTrue(true);
+ }
}
}
}