You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/02/26 18:51:41 UTC
[12/32] incubator-tinkerpop git commit: Ensured that
TraversalExplaination works for anonymous traversals (or any traversal that
has no strategies). Added TraversalExplanationTest that verifies correct
behavior. Fixed TINKERPOP-1175
Ensured that TraversalExplaination works for anonymous traversals (or any traversal that has no strategies). Added TraversalExplanationTest that verifies correct behavior. Fixed TINKERPOP-1175
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/15909c66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/15909c66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/15909c66
Branch: refs/heads/TINKERPOP-1166
Commit: 15909c669b40d08dde16c225ee818796252d6a79
Parents: c5447c2
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Feb 24 07:30:24 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Feb 24 07:30:24 2016 -0700
----------------------------------------------------------------------
.../traversal/util/TraversalExplanation.java | 4 +--
.../util/TraversalExplanationTest.java | 38 ++++++++++++++++++++
2 files changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/15909c66/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
index 97c7ab8..786b994 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
@@ -84,7 +84,7 @@ public class TraversalExplanation implements Serializable {
public String toString() {
final String originalTraversal = "Original Traversal";
final String finalTraversal = "Final Traversal";
- final int maxStrategyColumnLength = this.strategyTraversals.stream().map(Pair::getValue0).map(Object::toString).map(String::length).max(Comparator.<Integer>naturalOrder()).get();
+ final int maxStrategyColumnLength = this.strategyTraversals.stream().map(Pair::getValue0).map(Object::toString).map(String::length).max(Comparator.<Integer>naturalOrder()).orElse(15);
final int maxTraversalColumnLength = Stream.concat(Stream.of(Pair.with(null, this.traversal)), this.strategyTraversals.stream()).map(Pair::getValue1).map(Object::toString).map(String::length).max(Comparator.<Integer>naturalOrder()).get();
final StringBuilder builder = new StringBuilder("Traversal Explanation\n");
@@ -115,7 +115,7 @@ public class TraversalExplanation implements Serializable {
for (int i = 0; i < maxStrategyColumnLength - finalTraversal.length() + 7; i++) {
builder.append(" ");
}
- builder.append(this.strategyTraversals.get(this.strategyTraversals.size() - 1).getValue1());
+ builder.append(this.strategyTraversals.size() > 0 ? this.strategyTraversals.get(this.strategyTraversals.size() - 1).getValue1() : this.traversal);
return builder.toString();
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/15909c66/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
new file mode 100644
index 0000000..5b154a0
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.process.traversal.util;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class TraversalExplanationTest {
+
+ @Test
+ public void shouldSupportAnonymousTraversals() {
+ final String toString = __.out("knows").in("created").explain().toString();
+ assertTrue(toString.contains("Traversal Explanation"));
+ assertTrue(toString.contains("Original Traversal"));
+ assertTrue(toString.contains("Final Traversal"));
+ }
+}