Skip to content

Commit

Permalink
Try solving TeamCity errors in 5.26
Browse files Browse the repository at this point in the history
* Try solving TC errors in 5.25

* fix tests

* restored GephiMock
  • Loading branch information
vga91 committed Dec 19, 2024
1 parent 88c8970 commit de79ac3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
9 changes: 7 additions & 2 deletions extended/src/test/java/apoc/gephi/GephiMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.mockserver.client.MockServerClient;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.RegexBody;
import org.mockserver.socket.PortFactory;

import java.util.Arrays;
import java.util.HashSet;
Expand All @@ -26,9 +27,13 @@
*/
public class GephiMock {
private final ClientAndServer server;
private final int PORT;
public final String HOST;

public GephiMock() {
this.server = ClientAndServer.startClientAndServer(8080);
PORT = PortFactory.findFreePort();
HOST = "http://localhost:" + PORT;
this.server = ClientAndServer.startClientAndServer(PORT);
}

public void clearAllExpectations() {
Expand All @@ -40,7 +45,7 @@ public void shutdown() {
}

public void mockSuccess(String workspace, GephiEntity... entities) {
new MockServerClient("localhost", 8080)
new MockServerClient("localhost", PORT)
.when(request()
.withMethod("POST")
.withPath("/" + workspace)
Expand Down
30 changes: 18 additions & 12 deletions extended/src/test/java/apoc/gephi/GephiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public void testAdd() throws Exception {
node(0, "Foo"),
node(1, "Bar"),
relationship(0, "KNOWS",0, 1));
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p) yield nodes, relationships, format return *",
map("workspace", GEPHI_WORKSPACE),
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add($host,$workspace,p) yield nodes, relationships, format return *",
map("host", gephiMock.HOST,
"workspace", GEPHI_WORKSPACE),
r -> {
assertEquals(2L, r.get("nodes"));
assertEquals(1L, r.get("relationships"));
Expand All @@ -67,8 +68,9 @@ public void testWeightParameter() throws Exception {
node(0, "Foo"),
node(1, "Bar"),
relationship(0, "KNOWS",0, 1, "7.2"));
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p,'weight') yield nodes, relationships, format return *",
map("workspace", GEPHI_WORKSPACE),
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add($host,$workspace,p,'weight') yield nodes, relationships, format return *",
map("host", gephiMock.HOST,
"workspace", GEPHI_WORKSPACE),
r -> {
assertEquals(2L, r.get("nodes"));
assertEquals(1L, r.get("relationships"));
Expand All @@ -83,8 +85,9 @@ public void testWrongWeightParameter() throws Exception {
node(0, "Foo"),
node(1, "Bar"),
relationship(0, "KNOWS",0, 1));
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p,'test') yield nodes, relationships, format return *",
map("workspace", GEPHI_WORKSPACE),
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add($host,$workspace,p,'test') yield nodes, relationships, format return *",
map("host", gephiMock.HOST,
"workspace", GEPHI_WORKSPACE),
r -> {
assertEquals(2L, r.get("nodes"));
assertEquals(1L, r.get("relationships"));
Expand All @@ -99,8 +102,9 @@ public void testRightExportParameter() throws Exception {
node(0, "Foo"),
node(1, "Bar"),
relationship(0, "KNOWS",0, 1, "7.2", Set.of("foo")));
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p,'weight',['foo']) yield nodes, relationships, format return *",
map("workspace", GEPHI_WORKSPACE),
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add($host,$workspace,p,'weight',['foo']) yield nodes, relationships, format return *",
map("host", gephiMock.HOST,
"workspace", GEPHI_WORKSPACE),
r -> {
assertEquals(2L, r.get("nodes"));
assertEquals(1L, r.get("relationships"));
Expand All @@ -115,8 +119,9 @@ public void testWrongExportParameter() throws Exception {
node(0, "Foo"),
node(1, "Bar"),
relationship(0, "KNOWS",0, 1, "7.2"));
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p,'weight',['faa','fee']) yield nodes, relationships, format return *",
map("workspace", GEPHI_WORKSPACE),
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add($host,$workspace,p,'weight',['faa','fee']) yield nodes, relationships, format return *",
map("host", gephiMock.HOST,
"workspace", GEPHI_WORKSPACE),
r -> {
assertEquals(2L, r.get("nodes"));
assertEquals(1L, r.get("relationships"));
Expand All @@ -131,8 +136,9 @@ public void reservedExportParameter() throws Exception {
node(0, "Foo"),
node(1, "Bar"),
relationship(0, "KNOWS",0, 1, "7.2"));
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add(null,$workspace,p,'weight',['directed','label']) yield nodes, relationships, format return *",
map("workspace", GEPHI_WORKSPACE),
testCall(db, "MATCH p = (:Foo)-->() WITH p CALL apoc.gephi.add($host,$workspace,p,'weight',['directed','label']) yield nodes, relationships, format return *",
map("host", gephiMock.HOST,
"workspace", GEPHI_WORKSPACE),
r -> {
assertEquals(2L, r.get("nodes"));
assertEquals(1L, r.get("relationships"));
Expand Down

0 comments on commit de79ac3

Please # to comment.