Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
loveleif committed Jan 13, 2025
1 parent 2f09f26 commit 5e1991c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
13 changes: 7 additions & 6 deletions core/src/main/java/apoc/refactor/GraphRefactoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,21 +913,22 @@ private void mergeNodes(Node source, Node target, RefactorConfig conf, List<Stri

private void copyRelationships(Node source, Node target, boolean delete, boolean createNewSelfRel) {
for (Relationship rel : source.getRelationships()) {
final var type = rel.getType();
var startNode = rel.getStartNode();
if (startNode.getElementId().equals(source.getElementId())) startNode = target;
var endNode = rel.getEndNode();

if (!createNewSelfRel && startNode.getElementId().equals(endNode.getElementId())) continue;

if (startNode.getElementId().equals(source.getElementId())) startNode = target;
if (endNode.getElementId().equals(source.getElementId())) endNode = target;

final var type = rel.getType();
final var properties = rel.getAllProperties();

// Delete first to avoid breaking constraints.
if (delete) rel.delete();

if (createNewSelfRel || !startNode.getElementId().equals(endNode.getElementId())) {
final var newRel = startNode.createRelationshipTo(endNode, type);
properties.forEach(newRel::setProperty);
}
final var newRel = startNode.createRelationshipTo(endNode, type);
properties.forEach(newRel::setProperty);
}
}
}
4 changes: 4 additions & 0 deletions core/src/test/java/apoc/ArgumentDescriptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;

import apoc.agg.CollAggregation;
import apoc.agg.Graph;
Expand Down Expand Up @@ -329,7 +330,10 @@ private void generate(CypherVersion version, Function<CypherVersion, JsonNode> s
System.out.println("common:");
System.out.println(writer.writeValueAsString(commonJson));
System.out.println();
System.out.println("=".repeat(80));
System.out.println();
System.out.println("cypher %s specific:".formatted(version.versionName));
System.out.println(writer.writeValueAsString(specificJson));
fail("Remove call to generate");
}
}
24 changes: 21 additions & 3 deletions core/src/test/resources/procedures/common/procedures.json
Original file line number Diff line number Diff line change
Expand Up @@ -6138,7 +6138,7 @@
} ]
}, {
"isDeprecated" : false,
"signature" : "apoc.refactor.from(rel :: RELATIONSHIP, newNode :: NODE) :: (input :: INTEGER, output :: RELATIONSHIP, error :: STRING)",
"signature" : "apoc.refactor.from(rel :: RELATIONSHIP, newNode :: NODE, config = {} :: MAP) :: (input :: INTEGER, output :: RELATIONSHIP, error :: STRING)",
"name" : "apoc.refactor.from",
"description" : "Redirects the given `RELATIONSHIP` to the given start `NODE`.",
"returnDescription" : [ {
Expand Down Expand Up @@ -6168,10 +6168,16 @@
"description" : "The node to redirect the given relationship to.",
"isDeprecated" : false,
"type" : "NODE"
}, {
"name" : "config",
"description" : "{\n failOnErrors = false :: BOOLEAN\n}\n",
"isDeprecated" : false,
"default" : "DefaultParameterValue{value={}, type=MAP}",
"type" : "MAP"
} ]
}, {
"isDeprecated" : false,
"signature" : "apoc.refactor.invert(rel :: RELATIONSHIP) :: (input :: INTEGER, output :: RELATIONSHIP, error :: STRING)",
"signature" : "apoc.refactor.invert(rel :: RELATIONSHIP, config = {} :: MAP) :: (input :: INTEGER, output :: RELATIONSHIP, error :: STRING)",
"name" : "apoc.refactor.invert",
"description" : "Inverts the direction of the given `RELATIONSHIP`.",
"returnDescription" : [ {
Expand All @@ -6196,6 +6202,12 @@
"description" : "The relationship to reverse.",
"isDeprecated" : false,
"type" : "RELATIONSHIP"
}, {
"name" : "config",
"description" : "{\n failOnErrors = false :: BOOLEAN\n}\n",
"isDeprecated" : false,
"default" : "DefaultParameterValue{value={}, type=MAP}",
"type" : "MAP"
} ]
}, {
"isDeprecated" : false,
Expand Down Expand Up @@ -6662,7 +6674,7 @@
} ]
}, {
"isDeprecated" : false,
"signature" : "apoc.refactor.to(rel :: RELATIONSHIP, endNode :: NODE) :: (input :: INTEGER, output :: RELATIONSHIP, error :: STRING)",
"signature" : "apoc.refactor.to(rel :: RELATIONSHIP, endNode :: NODE, config = {} :: MAP) :: (input :: INTEGER, output :: RELATIONSHIP, error :: STRING)",
"name" : "apoc.refactor.to",
"description" : "Redirects the given `RELATIONSHIP` to the given end `NODE`.",
"returnDescription" : [ {
Expand Down Expand Up @@ -6692,6 +6704,12 @@
"description" : "The new end node the relationship should point to.",
"isDeprecated" : false,
"type" : "NODE"
}, {
"name" : "config",
"description" : "{\n failOnErrors = false :: BOOLEAN\n}\n",
"isDeprecated" : false,
"default" : "DefaultParameterValue{value={}, type=MAP}",
"type" : "MAP"
} ]
}, {
"isDeprecated" : false,
Expand Down

0 comments on commit 5e1991c

Please sign in to comment.