Skip to content

Commit 7127cf3

Browse files
committed
Remove dependency on common; split APOC core and APOC extended up to be less reliant on eachother
1 parent b24d774 commit 7127cf3

File tree

408 files changed

+17848
-2061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

408 files changed

+17848
-2061
lines changed

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "apoc-core"]
22
path = apoc-core
33
url = https://github.com/neo4j/apoc
4-
branch = dev
4+
branch = dev_remove_common

extended-it/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ dependencies {
3535

3636
testImplementation project(':core')
3737
testImplementation project(':test-utils')
38-
testImplementation project(':common')
3938
testImplementation project(':extended')
4039
testImplementation project(':core').sourceSets.test.output
4140
compileOnly project(':extended').sourceSets.main.allJava

extended-it/src/test/java/apoc/MissingExtraDependenciesTest.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package apoc;
22

3-
import apoc.util.MissingDependencyException;
3+
import apoc.util.MissingDependencyExceptionExtended;
44
import apoc.util.Neo4jContainerExtension;
55
import apoc.util.TestContainerUtil;
66
import org.junit.AfterClass;
@@ -15,7 +15,6 @@
1515

1616
import static apoc.couchbase.Couchbase.COUCHBASE_MISSING_DEPS_ERROR;
1717
import static apoc.data.email.ExtractEmail.EMAIL_MISSING_DEPS_ERROR;
18-
import static apoc.export.parquet.ParquetConfig.PARQUET_MISSING_DEPS_ERROR;
1918
import static apoc.export.xls.ExportXlsHandler.XLS_MISSING_DEPS_ERROR;
2019
import static apoc.load.LoadHtml.SELENIUM_MISSING_DEPS_ERROR;
2120
import static apoc.mongodb.MongoDBUtils.MONGO_MISSING_DEPS_ERROR;
@@ -27,7 +26,7 @@
2726

2827
/**
2928
* This test verifies that, if the `extra-dependencies` jars are not present,
30-
* the procedures that require them fail with {@link apoc.util.MissingDependencyException}
29+
* the procedures that require them fail with {@link MissingDependencyExceptionExtended}
3130
*/
3231
public class MissingExtraDependenciesTest {
3332
private static Neo4jContainerExtension neo4jContainer;
@@ -155,7 +154,7 @@ public static void assertFails(String query, Map<String, Object> params, String
155154
} catch (RuntimeException e) {
156155
String message = e.getMessage();
157156
// String of type `apoc.util.MissingDependencyException: <errorMessage>`
158-
String expected = "%s: %s".formatted(MissingDependencyException.class.getName(), errorMessage);
157+
String expected = "%s: %s".formatted(MissingDependencyExceptionExtended.class.getName(), errorMessage);
159158
assertTrue("Actual error message is: " + message, message.contains(expected));
160159
}
161160
}

extended-it/src/test/java/apoc/couchbase/CouchbaseIT.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import static apoc.couchbase.CouchbaseTestUtils.getNumConnections;
4343
import static apoc.util.TestUtil.testCall;
4444
import static apoc.util.TestUtil.testCallEmpty;
45-
import static apoc.util.Util.map;
45+
import static apoc.util.UtilExtended.map;
4646
import static org.junit.Assert.assertEquals;
4747
import static org.junit.Assert.assertFalse;
4848
import static org.junit.Assert.assertNull;

extended-it/src/test/java/apoc/es/ElasticSearchTest.java

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package apoc.es;
22

3-
import apoc.es.ElasticSearch;
4-
import apoc.util.JsonUtil;
3+
import apoc.util.JsonUtilExtended;
54
import apoc.util.TestUtil;
6-
import apoc.util.Util;
5+
import apoc.util.UtilExtended;
76
import com.fasterxml.jackson.core.JsonProcessingException;
87
import com.jayway.jsonpath.Configuration;
98
import com.jayway.jsonpath.JsonPath;
@@ -21,7 +20,7 @@
2120
import java.util.function.Consumer;
2221

2322
import static apoc.ApocConfig.apocConfig;
24-
import static apoc.util.MapUtil.map;
23+
import static apoc.util.MapUtilExtended.map;
2524
import static org.junit.Assert.assertEquals;
2625
import static org.junit.Assert.assertNotNull;
2726

@@ -96,15 +95,15 @@ public static void tearDown() {
9695
*/
9796
static Map<String, Object> createDefaultProcedureParametersWithPayloadAndId(String payload, String id) {
9897
try {
99-
Map mapPayload = JsonUtil.OBJECT_MAPPER.readValue(payload, Map.class);
98+
Map mapPayload = JsonUtilExtended.OBJECT_MAPPER.readValue(payload, Map.class);
10099
return addPayloadAndIdToParams(paramsWithBasicAuth, mapPayload, id);
101100
} catch (IOException e) {
102101
throw new RuntimeException(e);
103102
}
104103
}
105104

106105
static Map<String, Object> addPayloadAndIdToParams(Map<String, Object> params, Object payload, String id) {
107-
return Util.merge(params, Util.map("payload", payload, "id", id));
106+
return UtilExtended.merge(params, UtilExtended.map("payload", payload, "id", id));
108107
}
109108

110109
private static void insertDocuments() throws JsonProcessingException {
@@ -289,9 +288,9 @@ public void testFullSearchWithOtherParametersAsAString() throws Exception {
289288
*/
290289
@Test
291290
public void testPutUpdateDocument() throws IOException{
292-
Map<String, Object> doc = JsonUtil.OBJECT_MAPPER.readValue(DOCUMENT, Map.class);
291+
Map<String, Object> doc = JsonUtilExtended.OBJECT_MAPPER.readValue(DOCUMENT, Map.class);
293292
doc.put("tags", Arrays.asList("awesome"));
294-
Map<String, Object> params = createDefaultProcedureParametersWithPayloadAndId(JsonUtil.OBJECT_MAPPER.writeValueAsString(doc), ES_ID);
293+
Map<String, Object> params = createDefaultProcedureParametersWithPayloadAndId(JsonUtilExtended.OBJECT_MAPPER.writeValueAsString(doc), ES_ID);
295294
TestUtil.testCall(db, "CALL apoc.es.put($host,$index,$type,$id,'refresh=true',$payload, $config) yield value", params, r -> {
296295
Object updated = extractValueFromResponse(r, "$.result");
297296
assertEquals("updated", updated);
@@ -307,7 +306,7 @@ public void testPutUpdateDocument() throws IOException{
307306
public void testPutUpdateDocumentWithAuthHeader() throws IOException{
308307
String tags = UUID.randomUUID().toString();
309308

310-
Map<String, Object> doc = JsonUtil.OBJECT_MAPPER.readValue(DOCUMENT, Map.class);
309+
Map<String, Object> doc = JsonUtilExtended.OBJECT_MAPPER.readValue(DOCUMENT, Map.class);
311310
doc.put("tags", Arrays.asList(tags));
312311
Map<String, Object> params = addPayloadAndIdToParams(paramsWithBasicAuth, doc, ES_ID);
313312
TestUtil.testCall(db, "CALL apoc.es.put($host,$index,$type,$id,'refresh=true',$payload, $config) yield value",
@@ -330,8 +329,8 @@ public void testPostRawCreateDocument() throws IOException {
330329
String index = UUID.randomUUID().toString();
331330
String type = getEsType();
332331
String id = UUID.randomUUID().toString();
333-
Map payload = JsonUtil.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
334-
Map params = Util.map("host", HTTP_HOST_ADDRESS,
332+
Map payload = JsonUtilExtended.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
333+
Map params = UtilExtended.map("host", HTTP_HOST_ADDRESS,
335334
"index", index,
336335
"suffix", index,
337336
"type", type,
@@ -362,8 +361,8 @@ public void testPostRawCreateDocument() throws IOException {
362361
public void testPostCreateDocumentWithAuthHeader() throws IOException {
363362
String index = UUID.randomUUID().toString();
364363
String type = getEsType();
365-
Map payload = JsonUtil.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
366-
Map params = Util.map("host", elastic.getHttpHostAddress(),
364+
Map payload = JsonUtilExtended.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
365+
Map params = UtilExtended.map("host", elastic.getHttpHostAddress(),
367366
"index", index,
368367
"type", type,
369368
"payload", payload,

extended-it/src/test/java/apoc/es/ElasticVersionEightTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package apoc.es;
22

3-
import apoc.util.JsonUtil;
3+
import apoc.util.JsonUtilExtended;
44
import apoc.util.TestUtil;
5-
import apoc.util.Util;
5+
import apoc.util.UtilExtended;
66
import com.fasterxml.jackson.core.JsonProcessingException;
77
import com.nimbusds.jose.util.Pair;
88
import org.junit.BeforeClass;
@@ -22,7 +22,7 @@ public class ElasticVersionEightTest extends ElasticSearchTest {
2222
@BeforeClass
2323
public static void setUp() throws Exception {
2424
Map<String, Object> config = Map.of("headers", basicAuthHeader, VERSION_KEY, ElasticSearchHandler.Version.EIGHT.name());
25-
Map<String, Object> params = Util.map("index", ES_INDEX,
25+
Map<String, Object> params = UtilExtended.map("index", ES_INDEX,
2626
"id", ES_ID, "type", ES_TYPE, "config", config);
2727

2828
String tag = "8.14.3";
@@ -180,7 +180,7 @@ private void assertPutForRRF() {
180180

181181
payloads.forEach(payload -> {
182182
try {
183-
Map mapPayload = JsonUtil.OBJECT_MAPPER.readValue(payload.getRight(), Map.class);
183+
Map mapPayload = JsonUtilExtended.OBJECT_MAPPER.readValue(payload.getRight(), Map.class);
184184
paramsWithBasicAuth.put("payload", mapPayload);
185185
paramsWithBasicAuth.put("index", payload.getLeft());
186186
TestUtil.testCall(db, "CALL apoc.es.put($host, $index, null, null, null, $payload, $config)",
@@ -197,7 +197,7 @@ private void assertPutForRRF() {
197197
}
198198

199199
private void setPayload(String payload, Map<String, Object> params) throws JsonProcessingException {
200-
Map<String, Object> mapPayload = JsonUtil.OBJECT_MAPPER.readValue(payload, Map.class);
200+
Map<String, Object> mapPayload = JsonUtilExtended.OBJECT_MAPPER.readValue(payload, Map.class);
201201
params.put("payload", mapPayload);
202202
}
203203

extended-it/src/test/java/apoc/es/ElasticVersionSevenTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package apoc.es;
22

33
import apoc.util.TestUtil;
4-
import apoc.util.Util;
4+
import apoc.util.UtilExtended;
55
import org.junit.BeforeClass;
66
import org.junit.Test;
77

@@ -21,7 +21,7 @@ public class ElasticVersionSevenTest extends ElasticSearchTest {
2121
private final static String HOST = "localhost";
2222
public static final ElasticSearchHandler DEFAULT_HANDLER = ElasticSearchHandler.Version.DEFAULT.get();
2323

24-
private static final Map<String, Object> defaultParams = Util.map("index", ES_INDEX, "type", ES_TYPE, "id", ES_ID);
24+
private static final Map<String, Object> defaultParams = UtilExtended.map("index", ES_INDEX, "type", ES_TYPE, "id", ES_ID);
2525

2626
@BeforeClass
2727
public static void setUp() throws Exception {

extended-it/src/test/java/apoc/load/MySQLJdbcTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import apoc.util.s3.MySQLContainerExtension;
44
import apoc.util.TestUtil;
5-
import apoc.util.Util;
5+
import apoc.util.UtilExtended;
66
import org.junit.AfterClass;
77
import org.junit.BeforeClass;
88
import org.junit.ClassRule;
@@ -91,11 +91,11 @@ private static void testLoadJdbc(DbmsRule db, MySQLContainerExtension mysql) {
9191
// with the config {timezone: 'UTC'} and `preserveInstants=true&connectionTimeZone=SERVER` to make the result deterministic,
9292
// since `TIMESTAMP` values are automatically converted from the session time zone to UTC for storage, and vice versa.
9393
testCall(db, "CALL apoc.load.jdbc($url, $table, [], {timezone: 'UTC'})",
94-
Util.map(
94+
UtilExtended.map(
9595
"url", mysql.getJdbcUrl() + "&preserveInstants=true&connectionTimeZone=SERVER",
9696
"table", "country"),
9797
row -> {
98-
Map<String, Object> expected = Util.map(
98+
Map<String, Object> expected = UtilExtended.map(
9999
"Code", "NLD",
100100
"Name", "Netherlands",
101101
"Continent", "Europe",
@@ -125,7 +125,7 @@ private static void testLoadJdbc(DbmsRule db, MySQLContainerExtension mysql) {
125125

126126
private static void testIssue3496(DbmsRule db, MySQLContainerExtension mysql) {
127127
testCall(db, "CALL apoc.load.jdbc($url,'SELECT DATE(NOW()), NOW(), CURDATE(), CURTIME(), UTC_DATE(), UTC_TIME(), UTC_TIMESTAMP(), DATE(UTC_TIMESTAMP());')",
128-
Util.map("url", mysql.getJdbcUrl()),
128+
UtilExtended.map("url", mysql.getJdbcUrl()),
129129
r -> {
130130
Map row = (Map) r.get("row");
131131
assertEquals(8, row.size());

extended-it/src/test/java/apoc/load/PostgresJdbcTest.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import apoc.periodic.Periodic;
44
import apoc.text.Strings;
55
import apoc.util.TestUtil;
6-
import apoc.util.Util;
6+
import apoc.util.UtilExtended;
77
import org.junit.AfterClass;
88
import org.junit.BeforeClass;
99
import org.junit.ClassRule;
@@ -53,25 +53,25 @@ public static void tearDown() throws SQLException {
5353

5454
@Test
5555
public void testLoadJdbc() throws Exception {
56-
testCall(db, "CALL apoc.load.jdbc($url,'PERSON',[], $config)", Util.map("url", postgress.getJdbcUrl(),
57-
"config", Util.map("schema", "test",
58-
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
56+
testCall(db, "CALL apoc.load.jdbc($url,'PERSON',[], $config)", UtilExtended.map("url", postgress.getJdbcUrl(),
57+
"config", UtilExtended.map("schema", "test",
58+
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
5959
(row) -> assertResult(row));
6060
}
6161

6262
@Test
6363
public void testLoadJdbSelect() throws Exception {
64-
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM PERSON',[], $config)", Util.map("url", postgress.getJdbcUrl(),
65-
"config", Util.map("schema", "test",
66-
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
64+
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM PERSON',[], $config)", UtilExtended.map("url", postgress.getJdbcUrl(),
65+
"config", UtilExtended.map("schema", "test",
66+
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
6767
(row) -> assertResult(row));
6868
}
6969

7070
@Test
7171
public void testLoadJdbSelectWithArrays() throws Exception {
72-
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM ARRAY_TABLE',[], $config)", Util.map("url", postgress.getJdbcUrl(),
73-
"config", Util.map("schema", "test",
74-
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
72+
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM ARRAY_TABLE',[], $config)", UtilExtended.map("url", postgress.getJdbcUrl(),
73+
"config", UtilExtended.map("schema", "test",
74+
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
7575
(result) -> {
7676
Map<String, Object> row = (Map<String, Object>)result.get("row");
7777
assertEquals("John", row.get("NAME"));
@@ -85,27 +85,27 @@ public void testLoadJdbSelectWithArrays() throws Exception {
8585
@Test
8686
public void testLoadJdbcUpdate() throws Exception {
8787
testCall(db, "CALL apoc.load.jdbcUpdate($url,'UPDATE PERSON SET \"SURNAME\" = ? WHERE \"NAME\" = ?', ['DOE', 'John'], $config)",
88-
Util.map("url", postgress.getJdbcUrl(),
89-
"config", Util.map("schema", "test",
90-
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
91-
(row) -> assertEquals( Util.map("count", 1 ), row.get("row")));
88+
UtilExtended.map("url", postgress.getJdbcUrl(),
89+
"config", UtilExtended.map("schema", "test",
90+
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
91+
(row) -> assertEquals( UtilExtended.map("count", 1 ), row.get("row")));
9292
}
9393

9494
@Test
9595
public void testLoadJdbcParams() throws Exception {
9696
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM PERSON WHERE \"NAME\" = ?',['John'], $config)", // YIELD row RETURN row
97-
Util.map("url", postgress.getJdbcUrl(),
98-
"config", Util.map("schema", "test",
99-
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
97+
UtilExtended.map("url", postgress.getJdbcUrl(),
98+
"config", UtilExtended.map("schema", "test",
99+
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
100100
(row) -> assertResult(row));
101101
}
102102

103103
@Test
104104
@Ignore("flaky")
105105
public void testIssue4141PeriodicIterateWithJdbc() throws Exception {
106-
var config = Util.map("url", postgress.getJdbcUrl(),
107-
"config", Util.map("schema", "test",
108-
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword())));
106+
var config = UtilExtended.map("url", postgress.getJdbcUrl(),
107+
"config", UtilExtended.map("schema", "test",
108+
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword())));
109109

110110
String query = "WITH range(0, 100) as list UNWIND list as l CREATE (n:MyNode{id: l})";
111111

0 commit comments

Comments
 (0)