Skip to content

Commit

Permalink
[NOID] Fixes #3367: Test to check return type of apoc.any.rebind with…
Browse files Browse the repository at this point in the history
… a Path (#3848)
  • Loading branch information
vga91 committed Dec 22, 2023
1 parent c6becde commit 5678635
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion full/src/test/java/apoc/nodes/NodesExtendedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,28 @@ public void rebind() {
final List<Path> rebindList = (List<Path>) row.get("rebind");
assertEquals(2, rebindList.size());
final Path firstPath = rebindList.get(0);
assertPath(firstPath, List.of("Foo", "Bar"), List.of("MY_REL"));
assertFooBarPath(firstPath);
final Path secondPath = rebindList.get(1);
assertPath(secondPath, List.of("Bar", "Baz"), List.of("ANOTHER_REL"));
});

// check via `valueType()` that, even if the return type is Object,
// the output of a rebound Path is also a Path (i.e.: `PATH NOT NULL`)
TestUtil.testCall(db, """
CREATE path=(a:Foo)-[r1:MY_REL]->(b:Bar)\s
WITH apoc.any.rebind(path) AS rebind
RETURN rebind, valueType(rebind) as valueType""",
(row) -> {
final String valueType = (String) row.get("valueType");
assertEquals("PATH NOT NULL", valueType);

final Path pathRebind = (Path) row.get("rebind");
assertFooBarPath(pathRebind);
});
}

private void assertFooBarPath(Path pathRebind) {
assertPath(pathRebind, List.of("Foo", "Bar"), List.of("MY_REL"));
}

private void assertPath(Path rebind, List<String> labels, List<String> relTypes) {
Expand Down

0 comments on commit 5678635

Please sign in to comment.