|
36 | 36 | import static org.neo4j.graphdb.traversal.Evaluators.toDepth; |
37 | 37 |
|
38 | 38 | import apoc.HelperProcedures; |
| 39 | +import apoc.example.Examples; |
39 | 40 | import apoc.graph.Graphs; |
40 | 41 | import apoc.nodes.Nodes; |
41 | 42 | import apoc.util.MapUtil; |
@@ -104,7 +105,13 @@ void configure(TestDatabaseManagementServiceBuilder builder) { |
104 | 105 | @BeforeAll |
105 | 106 | void setUp() { |
106 | 107 | TestUtil.registerProcedure( |
107 | | - db, Meta.class, MetaRestricted.class, Graphs.class, Nodes.class, HelperProcedures.class); |
| 108 | + db, |
| 109 | + Meta.class, |
| 110 | + MetaRestricted.class, |
| 111 | + Graphs.class, |
| 112 | + Nodes.class, |
| 113 | + HelperProcedures.class, |
| 114 | + Examples.class); |
108 | 115 | } |
109 | 116 |
|
110 | 117 | public static boolean hasRecordMatching(List<Map<String, Object>> records, Map<String, Object> record) { |
@@ -666,6 +673,39 @@ private void assertRowMetaData(Map<String, Object> row, long count, long left, l |
666 | 673 | assertEquals(type.name(), row.get("type")); |
667 | 674 | } |
668 | 675 |
|
| 676 | + @Test |
| 677 | + void testMetaSchemaOutgoingRelCountBug() { |
| 678 | + db.executeTransactionally("CALL apoc.example.movies()"); |
| 679 | + testCall(db, "CALL apoc.meta.schema()", (row) -> { |
| 680 | + Map<String, Object> schema = (Map<String, Object>) row.get("value"); |
| 681 | + |
| 682 | + Map<String, Object> actorRels = |
| 683 | + (Map<String, Object>) ((Map<String, Object>) schema.get("Person")).get("relationships"); |
| 684 | + Map<String, Object> movieRels = |
| 685 | + (Map<String, Object>) ((Map<String, Object>) schema.get("Movie")).get("relationships"); |
| 686 | + |
| 687 | + assertRelationship(actorRels, "DIRECTED", "out", 44); |
| 688 | + assertRelationship(actorRels, "ACTED_IN", "out", 172); |
| 689 | + assertRelationship(actorRels, "REVIEWED", "out", 8); |
| 690 | + assertRelationship(actorRels, "PRODUCED", "out", 14); |
| 691 | + assertRelationship(actorRels, "WROTE", "out", 9); |
| 692 | + |
| 693 | + assertRelationship(movieRels, "DIRECTED", "in", 44); |
| 694 | + assertRelationship(movieRels, "ACTED_IN", "in", 172); |
| 695 | + assertRelationship(movieRels, "REVIEWED", "in", 8); |
| 696 | + assertRelationship(movieRels, "PRODUCED", "in", 14); |
| 697 | + assertRelationship(movieRels, "WROTE", "in", 9); |
| 698 | + }); |
| 699 | + } |
| 700 | + |
| 701 | + private void assertRelationship(Map<String, Object> relationships, String relType, String direction, long count) { |
| 702 | + Map<String, Object> rel = (Map<String, Object>) relationships.get(relType); |
| 703 | + |
| 704 | + assertNotNull(rel, "Relationship " + relType + " should not be null"); |
| 705 | + assertEquals(direction, rel.get("direction")); |
| 706 | + assertEquals(count, (long) rel.get("count")); |
| 707 | + } |
| 708 | + |
669 | 709 | @Test |
670 | 710 | void testOutgoingRelsAreCorrectMetaSchema() { |
671 | 711 | db.executeTransactionally("CREATE (:A)-[:HAS]->(:B), (:A)<-[:HAS]-(:B), (:A)<-[:HAS]-(:C), (:D)<-[:HAS]-(:E)"); |
|
0 commit comments