Skip to content

Commit

Permalink
Fix broken test and review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lojjs committed Oct 15, 2018
1 parent 31a16b6 commit d579162
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
Expand Up @@ -147,6 +147,8 @@ public void listProcedures() throws Throwable
proc( "db.labels", "() :: (label :: STRING?)", "List all labels in the database.", "READ" ), proc( "db.labels", "() :: (label :: STRING?)", "List all labels in the database.", "READ" ),
proc( "db.schema", "() :: (nodes :: LIST? OF NODE?, relationships :: LIST? " + "OF " + "RELATIONSHIP?)", proc( "db.schema", "() :: (nodes :: LIST? OF NODE?, relationships :: LIST? " + "OF " + "RELATIONSHIP?)",
"Show the schema of the data.", "READ" ), "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?, " + 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.", "cypherTypes :: LIST? OF STRING?, nullable :: BOOLEAN?)", "Show the derived property schema of the data in tabular form.",
"READ" ), "READ" ),
Expand Down
Expand Up @@ -78,6 +78,7 @@ public class BuiltInProcedures
{ {
private static final int NOT_EXISTING_INDEX_ID = -1; 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 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 @Context
public KernelTransaction tx; public KernelTransaction tx;
Expand Down Expand Up @@ -222,16 +223,16 @@ public Stream<SchemaInfoResult> propertySchema()
} }


@Deprecated @Deprecated
@Description( "Show the schema of the data. Replaced by db.schema.visualization." ) @Description( "Show the schema of the data." )
@Procedure( name = "db.schema", mode = READ ) @Procedure( name = "db.schema", mode = READ, deprecatedBy = DB_SCHEMA_DEPRECATION )
public Stream<SchemaProcedure.GraphResult> metaGraph() public Stream<SchemaProcedure.GraphResult> schema()
{ {
return metaGraphVisualization(); return schemaVisualization();
} }


@Description( "Visualize the schema of the data. Replaces db.schema." ) @Description( "Visualize the schema of the data. Replaces db.schema." )
@Procedure( name = "db.schema.visualization", mode = READ ) @Procedure( name = "db.schema.visualization", mode = READ )
public Stream<SchemaProcedure.GraphResult> metaGraphVisualization() public Stream<SchemaProcedure.GraphResult> schemaVisualization()
{ {
return Stream.of( new SchemaProcedure( graphDatabaseAPI, tx ).buildSchemaGraph() ); return Stream.of( new SchemaProcedure( graphDatabaseAPI, tx ).buildSchemaGraph() );
} }
Expand Down
Expand Up @@ -285,7 +285,7 @@ public void shouldListCorrectBuiltinProcedures() throws Throwable
"Schedule resampling of all outdated indexes.", "READ" ), "Schedule resampling of all outdated indexes.", "READ" ),
record( "db.schema", record( "db.schema",
"db.schema() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)", "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", record( "db.schema.visualization",
"db.schema.visualization() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)", "db.schema.visualization() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)",
"Visualize the schema of the data. Replaces db.schema.", "READ" ), "Visualize the schema of the data. Replaces db.schema.", "READ" ),
Expand Down
Expand Up @@ -89,6 +89,42 @@ class BuiltInProcedureAcceptanceTest extends ProcedureCallAcceptanceTest with Cy
relationshipState should equal(Set("WORKS_AT", "PART_OF")) 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") { test("should not be able to filter as part of standalone call") {
failWithError( failWithError(
Configs.AbsolutelyAll - Configs.Version2_3, Configs.AbsolutelyAll - Configs.Version2_3,
Expand Down

0 comments on commit d579162

Please sign in to comment.