From d579162377264e9cc9e0ced9d177d8b37f9fa494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louise=20S=C3=B6derstr=C3=B6m?= Date: Fri, 12 Oct 2018 13:45:47 +0200 Subject: [PATCH] Fix broken test and review comments --- .../integrationtest/BuiltInProceduresIT.java | 2 ++ .../builtinprocs/BuiltInProcedures.java | 11 +++--- .../builtinprocs/BuiltInProceduresTest.java | 2 +- .../BuiltInProcedureAcceptanceTest.scala | 36 +++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java index 94c6a16e51a0a..0d99879ffec50 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/api/integrationtest/BuiltInProceduresIT.java @@ -147,6 +147,8 @@ public void listProcedures() throws Throwable proc( "db.labels", "() :: (label :: STRING?)", "List all labels in the database.", "READ" ), proc( "db.schema", "() :: (nodes :: LIST? OF NODE?, relationships :: LIST? " + "OF " + "RELATIONSHIP?)", "Show the schema of the data.", "READ" ), + proc( "db.schema.visualization","() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)", + "Visualize the schema of the data. Replaces db.schema.", "READ" ), proc( "okapi.schema", "() :: (type :: STRING?, nodeLabelsOrRelType :: LIST? OF STRING?, property :: STRING?, " + "cypherTypes :: LIST? OF STRING?, nullable :: BOOLEAN?)", "Show the derived property schema of the data in tabular form.", "READ" ), diff --git a/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java b/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java index 757edc83a0ac1..3c1e9c9721d0c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/builtinprocs/BuiltInProcedures.java @@ -78,6 +78,7 @@ public class BuiltInProcedures { private static final int NOT_EXISTING_INDEX_ID = -1; public static final String EXPLICIT_INDEX_DEPRECATION = "This procedure is deprecated by the schema and full-text indexes, and will be removed in 4.0."; + public static final String DB_SCHEMA_DEPRECATION = "This procedure is deprecated by the db.schema.visualization procedure, and will be removed in 4.0."; @Context public KernelTransaction tx; @@ -222,16 +223,16 @@ public Stream propertySchema() } @Deprecated - @Description( "Show the schema of the data. Replaced by db.schema.visualization." ) - @Procedure( name = "db.schema", mode = READ ) - public Stream metaGraph() + @Description( "Show the schema of the data." ) + @Procedure( name = "db.schema", mode = READ, deprecatedBy = DB_SCHEMA_DEPRECATION ) + public Stream schema() { - return metaGraphVisualization(); + return schemaVisualization(); } @Description( "Visualize the schema of the data. Replaces db.schema." ) @Procedure( name = "db.schema.visualization", mode = READ ) - public Stream metaGraphVisualization() + public Stream schemaVisualization() { return Stream.of( new SchemaProcedure( graphDatabaseAPI, tx ).buildSchemaGraph() ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java index 64b3804664190..5e721d3b1b6b4 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java @@ -285,7 +285,7 @@ public void shouldListCorrectBuiltinProcedures() throws Throwable "Schedule resampling of all outdated indexes.", "READ" ), record( "db.schema", "db.schema() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)", - "Show the schema of the data. Replaced by db.schema.visualization.", "READ" ), + "Show the schema of the data.", "READ" ), record( "db.schema.visualization", "db.schema.visualization() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)", "Visualize the schema of the data. Replaces db.schema.", "READ" ), diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/BuiltInProcedureAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/BuiltInProcedureAcceptanceTest.scala index be44a88d2a4c0..5c3dc47d753aa 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/BuiltInProcedureAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/BuiltInProcedureAcceptanceTest.scala @@ -89,6 +89,42 @@ class BuiltInProcedureAcceptanceTest extends ProcedureCallAcceptanceTest with Cy relationshipState should equal(Set("WORKS_AT", "PART_OF")) } + test("should be able to use db.schema.visualization") { + + // Given + val neo = createLabeledNode("Neo") + val d1 = createLabeledNode("Department") + val e1 = createLabeledNode("Employee") + relate(e1, d1, "WORKS_AT", "Hallo") + relate(d1, neo, "PART_OF", "Hallo") + + // When + val result = executeWith(config, "CALL db.schema.visualization()", expectedDifferentResults = config).toList + + // Then + result.size should equal(1) + + // And then nodes + val nodes = result.head("nodes").asInstanceOf[Seq[Node]] + + val nodeState: Set[(List[Label], Map[String,AnyRef])] = + nodes.map(n => (n.getLabels.toList, n.getAllProperties.toMap)).toSet + + val empty = new java.util.ArrayList() + nodeState should equal( + Set( + (List(Label.label("Neo")), Map("indexes" -> empty, "constraints" -> empty, "name" -> "Neo")), + (List(Label.label("Department")), Map("indexes" -> empty, "constraints" -> empty, "name" -> "Department")), + (List(Label.label("Employee")), Map("indexes" -> empty, "constraints" -> empty, "name" -> "Employee")) + )) + + // And then relationships + val relationships = result.head("relationships").asInstanceOf[Seq[Relationship]] + + val relationshipState: Set[String] = relationships.map(_.getType.name()).toSet + relationshipState should equal(Set("WORKS_AT", "PART_OF")) + } + test("should not be able to filter as part of standalone call") { failWithError( Configs.AbsolutelyAll - Configs.Version2_3,