Skip to content

Commit

Permalink
Remove dependency on common; split APOC core and APOC extended up to …
Browse files Browse the repository at this point in the history
…be less reliant on eachother
  • Loading branch information
gem-neo4j committed Dec 3, 2024
1 parent b24d774 commit 56f0610
Show file tree
Hide file tree
Showing 408 changed files with 17,846 additions and 2,058 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "apoc-core"]
path = apoc-core
url = https://github.com/neo4j/apoc
branch = dev
branch = dev_remove_common
1 change: 0 additions & 1 deletion extended-it/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dependencies {

testImplementation project(':core')
testImplementation project(':test-utils')
testImplementation project(':common')
testImplementation project(':extended')
testImplementation project(':core').sourceSets.test.output
compileOnly project(':extended').sourceSets.main.allJava
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package apoc;

import apoc.util.MissingDependencyException;
import apoc.util.MissingDependencyExceptionExtended;
import apoc.util.Neo4jContainerExtension;
import apoc.util.TestContainerUtil;
import org.junit.AfterClass;
Expand All @@ -15,7 +15,6 @@

import static apoc.couchbase.Couchbase.COUCHBASE_MISSING_DEPS_ERROR;
import static apoc.data.email.ExtractEmail.EMAIL_MISSING_DEPS_ERROR;
import static apoc.export.parquet.ParquetConfig.PARQUET_MISSING_DEPS_ERROR;
import static apoc.export.xls.ExportXlsHandler.XLS_MISSING_DEPS_ERROR;
import static apoc.load.LoadHtml.SELENIUM_MISSING_DEPS_ERROR;
import static apoc.mongodb.MongoDBUtils.MONGO_MISSING_DEPS_ERROR;
Expand All @@ -27,7 +26,7 @@

/**
* This test verifies that, if the `extra-dependencies` jars are not present,
* the procedures that require them fail with {@link apoc.util.MissingDependencyException}
* the procedures that require them fail with {@link MissingDependencyExceptionExtended}
*/
public class MissingExtraDependenciesTest {
private static Neo4jContainerExtension neo4jContainer;
Expand Down Expand Up @@ -155,7 +154,7 @@ public static void assertFails(String query, Map<String, Object> params, String
} catch (RuntimeException e) {
String message = e.getMessage();
// String of type `apoc.util.MissingDependencyException: <errorMessage>`
String expected = "%s: %s".formatted(MissingDependencyException.class.getName(), errorMessage);
String expected = "%s: %s".formatted(MissingDependencyExceptionExtended.class.getName(), errorMessage);
assertTrue("Actual error message is: " + message, message.contains(expected));
}
}
Expand Down
2 changes: 1 addition & 1 deletion extended-it/src/test/java/apoc/couchbase/CouchbaseIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import static apoc.couchbase.CouchbaseTestUtils.getNumConnections;
import static apoc.util.TestUtil.testCall;
import static apoc.util.TestUtil.testCallEmpty;
import static apoc.util.Util.map;
import static apoc.util.UtilExtended.map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
Expand Down
25 changes: 12 additions & 13 deletions extended-it/src/test/java/apoc/es/ElasticSearchTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package apoc.es;

import apoc.es.ElasticSearch;
import apoc.util.JsonUtil;
import apoc.util.JsonUtilExtended;
import apoc.util.TestUtil;
import apoc.util.Util;
import apoc.util.UtilExtended;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
Expand All @@ -21,7 +20,7 @@
import java.util.function.Consumer;

import static apoc.ApocConfig.apocConfig;
import static apoc.util.MapUtil.map;
import static apoc.util.MapUtilExtended.map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

Expand Down Expand Up @@ -96,15 +95,15 @@ public static void tearDown() {
*/
static Map<String, Object> createDefaultProcedureParametersWithPayloadAndId(String payload, String id) {
try {
Map mapPayload = JsonUtil.OBJECT_MAPPER.readValue(payload, Map.class);
Map mapPayload = JsonUtilExtended.OBJECT_MAPPER.readValue(payload, Map.class);
return addPayloadAndIdToParams(paramsWithBasicAuth, mapPayload, id);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

static Map<String, Object> addPayloadAndIdToParams(Map<String, Object> params, Object payload, String id) {
return Util.merge(params, Util.map("payload", payload, "id", id));
return UtilExtended.merge(params, UtilExtended.map("payload", payload, "id", id));
}

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

Map<String, Object> doc = JsonUtil.OBJECT_MAPPER.readValue(DOCUMENT, Map.class);
Map<String, Object> doc = JsonUtilExtended.OBJECT_MAPPER.readValue(DOCUMENT, Map.class);
doc.put("tags", Arrays.asList(tags));
Map<String, Object> params = addPayloadAndIdToParams(paramsWithBasicAuth, doc, ES_ID);
TestUtil.testCall(db, "CALL apoc.es.put($host,$index,$type,$id,'refresh=true',$payload, $config) yield value",
Expand All @@ -330,8 +329,8 @@ public void testPostRawCreateDocument() throws IOException {
String index = UUID.randomUUID().toString();
String type = getEsType();
String id = UUID.randomUUID().toString();
Map payload = JsonUtil.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
Map params = Util.map("host", HTTP_HOST_ADDRESS,
Map payload = JsonUtilExtended.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
Map params = UtilExtended.map("host", HTTP_HOST_ADDRESS,
"index", index,
"suffix", index,
"type", type,
Expand Down Expand Up @@ -362,8 +361,8 @@ public void testPostRawCreateDocument() throws IOException {
public void testPostCreateDocumentWithAuthHeader() throws IOException {
String index = UUID.randomUUID().toString();
String type = getEsType();
Map payload = JsonUtil.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
Map params = Util.map("host", elastic.getHttpHostAddress(),
Map payload = JsonUtilExtended.OBJECT_MAPPER.readValue("{\"ajeje\":\"Brazorf\"}", Map.class);
Map params = UtilExtended.map("host", elastic.getHttpHostAddress(),
"index", index,
"type", type,
"payload", payload,
Expand Down
10 changes: 5 additions & 5 deletions extended-it/src/test/java/apoc/es/ElasticVersionEightTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package apoc.es;

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

String tag = "8.14.3";
Expand Down Expand Up @@ -180,7 +180,7 @@ private void assertPutForRRF() {

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package apoc.es;

import apoc.util.TestUtil;
import apoc.util.Util;
import apoc.util.UtilExtended;
import org.junit.BeforeClass;
import org.junit.Test;

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

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

@BeforeClass
public static void setUp() throws Exception {
Expand Down
8 changes: 4 additions & 4 deletions extended-it/src/test/java/apoc/load/MySQLJdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

private static void testIssue3496(DbmsRule db, MySQLContainerExtension mysql) {
testCall(db, "CALL apoc.load.jdbc($url,'SELECT DATE(NOW()), NOW(), CURDATE(), CURTIME(), UTC_DATE(), UTC_TIME(), UTC_TIMESTAMP(), DATE(UTC_TIMESTAMP());')",
Util.map("url", mysql.getJdbcUrl()),
UtilExtended.map("url", mysql.getJdbcUrl()),
r -> {
Map row = (Map) r.get("row");
assertEquals(8, row.size());
Expand Down
40 changes: 20 additions & 20 deletions extended-it/src/test/java/apoc/load/PostgresJdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import apoc.periodic.Periodic;
import apoc.text.Strings;
import apoc.util.TestUtil;
import apoc.util.Util;
import apoc.util.UtilExtended;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
Expand Down Expand Up @@ -53,25 +53,25 @@ public static void tearDown() throws SQLException {

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

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

@Test
public void testLoadJdbSelectWithArrays() throws Exception {
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM ARRAY_TABLE',[], $config)", Util.map("url", postgress.getJdbcUrl(),
"config", Util.map("schema", "test",
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
testCall(db, "CALL apoc.load.jdbc($url,'SELECT * FROM ARRAY_TABLE',[], $config)", UtilExtended.map("url", postgress.getJdbcUrl(),
"config", UtilExtended.map("schema", "test",
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
(result) -> {
Map<String, Object> row = (Map<String, Object>)result.get("row");
assertEquals("John", row.get("NAME"));
Expand All @@ -85,27 +85,27 @@ public void testLoadJdbSelectWithArrays() throws Exception {
@Test
public void testLoadJdbcUpdate() throws Exception {
testCall(db, "CALL apoc.load.jdbcUpdate($url,'UPDATE PERSON SET \"SURNAME\" = ? WHERE \"NAME\" = ?', ['DOE', 'John'], $config)",
Util.map("url", postgress.getJdbcUrl(),
"config", Util.map("schema", "test",
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
(row) -> assertEquals( Util.map("count", 1 ), row.get("row")));
UtilExtended.map("url", postgress.getJdbcUrl(),
"config", UtilExtended.map("schema", "test",
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword()))),
(row) -> assertEquals( UtilExtended.map("count", 1 ), row.get("row")));
}

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

@Test
@Ignore("flaky")
public void testIssue4141PeriodicIterateWithJdbc() throws Exception {
var config = Util.map("url", postgress.getJdbcUrl(),
"config", Util.map("schema", "test",
"credentials", Util.map("user", postgress.getUsername(), "password", postgress.getPassword())));
var config = UtilExtended.map("url", postgress.getJdbcUrl(),
"config", UtilExtended.map("schema", "test",
"credentials", UtilExtended.map("user", postgress.getUsername(), "password", postgress.getPassword())));

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

Expand Down
Loading

0 comments on commit 56f0610

Please sign in to comment.