Repository: tinkerpop Updated Branches: refs/heads/TINKERPOP-1698 9ede1f0f0 -> 616a92a70 (forced update)
TINKERPOP-1445 Add ellipses for long property values Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/47afd7a6 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/47afd7a6 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/47afd7a6 Branch: refs/heads/TINKERPOP-1698 Commit: 47afd7a664ecb7c737341cac7c005e403c0b569e Parents: b026ca3 Author: Stephen Mallette <[email protected]> Authored: Sun Jun 18 14:25:15 2017 -0400 Committer: Stephen Mallette <[email protected]> Committed: Sun Jun 18 14:25:15 2017 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../gremlin/structure/util/StringFactory.java | 9 +++---- .../gremlin/structure/PropertyTest.java | 28 +++++++++++++++++++- 3 files changed, 31 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/47afd7a6/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index ff6ff24..eb8ad8a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* Included an ellipse on long property names that are truncated. * Renamed `RangeByIsCountStrategy` to `CountStrategy`. * Added more specific typing to various `__` traversal steps. E.g. `<A,Vertex>out()` is `<Vertex,Vertex>out()`. * Updated Docker build scripts to include Python dependencies (NOTE: users should remove any previously generated TinkerPop Docker images). http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/47afd7a6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java index bcead2d..0a1cdb6 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/StringFactory.java @@ -18,6 +18,7 @@ */ package org.apache.tinkerpop.gremlin.structure.util; +import org.apache.commons.lang.StringUtils; import org.apache.tinkerpop.gremlin.process.computer.Computer; import org.apache.tinkerpop.gremlin.process.computer.ComputerResult; import org.apache.tinkerpop.gremlin.process.computer.GraphComputer; @@ -68,12 +69,8 @@ public final class StringFactory { private static final String L_BRACKET = "["; private static final String R_BRACKET = "]"; private static final String COMMA_SPACE = ", "; - private static final String COLON = ":"; - private static final String EMPTY_MAP = "{}"; - private static final String DOTS = "..."; private static final String DASH = "-"; private static final String ARROW = "->"; - private static final String STAR = "*"; private static final String EMPTY_PROPERTY = "p[empty]"; private static final String EMPTY_VERTEX_PROPERTY = "vp[empty]"; private static final String LINE_SEPARATOR = System.getProperty("line.separator"); @@ -106,11 +103,11 @@ public final class StringFactory { if (property instanceof VertexProperty) { if (!property.isPresent()) return EMPTY_VERTEX_PROPERTY; final String valueString = String.valueOf(property.value()); - return VP + L_BRACKET + property.key() + ARROW + valueString.substring(0, Math.min(valueString.length(), 20)) + R_BRACKET; + return VP + L_BRACKET + property.key() + ARROW + StringUtils.abbreviate(valueString, 20) + R_BRACKET; } else { if (!property.isPresent()) return EMPTY_PROPERTY; final String valueString = String.valueOf(property.value()); - return P + L_BRACKET + property.key() + ARROW + valueString.substring(0, Math.min(valueString.length(), 20)) + R_BRACKET; + return P + L_BRACKET + property.key() + ARROW + StringUtils.abbreviate(valueString, 20) + R_BRACKET; } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/47afd7a6/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/PropertyTest.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/PropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/PropertyTest.java index 43439c8..cb47043 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/PropertyTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/PropertyTest.java @@ -59,7 +59,7 @@ public class PropertyTest { public static class BasicPropertyTest extends AbstractGremlinTest { @Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) - public void shouldHaveStandardStringRepresentation() { + public void shouldHaveStandardStringRepresentationForVertexProperty() { final Vertex v = graph.addVertex("name", "marko"); final Property p = v.property("name"); assertEquals(StringFactory.propertyString(p), p.toString()); @@ -67,6 +67,32 @@ public class PropertyTest { @Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldHaveTruncatedStringRepresentationForVertexProperty() { + final Vertex v = graph.addVertex("name", "maria de la santa cruz rosalina agnelia rodriguez cuellar rene"); + final Property p = v.property("name"); + assertEquals(StringFactory.propertyString(p), p.toString()); + } + + @Test + @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) + public void shouldHaveStandardStringRepresentationForEdgeProperty() { + final Vertex v = graph.addVertex(); + final Edge e = v.addEdge("self", v, "short", "s"); + final Property p = e.property("short"); + assertEquals(StringFactory.propertyString(p), p.toString()); + } + + @Test + @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) + public void shouldHaveTruncatedStringRepresentationForEdgeProperty() { + final Vertex v = graph.addVertex(); + final Edge e = v.addEdge("self", v, "long", "s"); + final Property p = e.property("long", "this is a really long property to truncate"); + assertEquals(StringFactory.propertyString(p), p.toString()); + } + + @Test + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldReturnEmptyPropertyIfKeyNonExistent() { final Vertex v = graph.addVertex("name", "marko"); tryCommit(graph, (graph) -> {
