From dbeb15cbc250ab307eb913aa877aeb7ac8ab8ff8 Mon Sep 17 00:00:00 2001 From: vga91 Date: Mon, 20 Nov 2023 11:41:55 +0100 Subject: [PATCH] Fixes #3367: Test to check return type of apoc.any.rebind with a Path --- .../java/apoc/nodes/NodesExtendedTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/extended/src/test/java/apoc/nodes/NodesExtendedTest.java b/extended/src/test/java/apoc/nodes/NodesExtendedTest.java index e0411c0297..f16514ed4c 100644 --- a/extended/src/test/java/apoc/nodes/NodesExtendedTest.java +++ b/extended/src/test/java/apoc/nodes/NodesExtendedTest.java @@ -51,10 +51,28 @@ public void rebind() { final List rebindList = (List) 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 labels, List relTypes) {