From 7648b543a11f545d7b44bd1822456588e9fd870c Mon Sep 17 00:00:00 2001 From: Giuseppe Villani Date: Fri, 1 Dec 2023 13:34:56 +0100 Subject: [PATCH] [NOID] Fixes #3367: Test to check return type of apoc.any.rebind with a Path (#3848) --- .../java/apoc/nodes/NodesExtendedTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/full/src/test/java/apoc/nodes/NodesExtendedTest.java b/full/src/test/java/apoc/nodes/NodesExtendedTest.java index a62c534e80..20d2fdaa7b 100644 --- a/full/src/test/java/apoc/nodes/NodesExtendedTest.java +++ b/full/src/test/java/apoc/nodes/NodesExtendedTest.java @@ -77,10 +77,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) {