Skip to content

Commit

Permalink
[kAAv6pCq] Cherry pick test fixes to 4.4 (#3784)
Browse files Browse the repository at this point in the history
  • Loading branch information
gem-neo4j authored Oct 2, 2023
1 parent f822db1 commit 03f19a1
Show file tree
Hide file tree
Showing 54 changed files with 1,390 additions and 2,282 deletions.
26 changes: 7 additions & 19 deletions core-it/src/test/java/apoc/core/it/CollEnterpriseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
import org.neo4j.driver.Session;

import static apoc.util.TestContainerUtil.createEnterpriseDB;
import static apoc.util.TestUtil.isRunningInCI;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

public class CollEnterpriseTest {

Expand All @@ -43,35 +39,27 @@ public class CollEnterpriseTest {

@BeforeAll
public static void beforeAll() {
assumeFalse(isRunningInCI());
TestUtil.ignoreException(() -> {
// We build the project, the artifact will be placed into ./build/libs
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI());
neo4jContainer.start();
}, Exception.class);
assumeTrue(neo4jContainer.isRunning());
assumeNotNull(neo4jContainer);
assumeTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
// We build the project, the artifact will be placed into ./build/libs
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI());
neo4jContainer.start();
session = neo4jContainer.getSession();
}

@AfterAll
public static void afterAll() {
if (neo4jContainer != null && neo4jContainer.isRunning()) {
session.close();
neo4jContainer.close();
}
session.close();
neo4jContainer.close();
}

@RepeatedTest(50)
public void testMin() throws Exception {
public void testMin() {
assertEquals(1L, session.run("RETURN apoc.coll.min([1,2]) as value").next().get("value").asLong());
assertEquals(1L, session.run("RETURN apoc.coll.min([1,2,3]) as value").next().get("value").asLong());
assertEquals(0.5D, session.run("RETURN apoc.coll.min([0.5,1,2.3]) as value").next().get("value").asDouble(), 0.1);
}

@RepeatedTest(50)
public void testMax() throws Exception {
public void testMax() {
assertEquals(3L, session.run("RETURN apoc.coll.max([1,2,3]) as value").next().get("value").asLong());
assertEquals(2.3D, session.run("RETURN apoc.coll.max([0.5,1,2.3]) as value").next().get("value").asDouble(), 0.1);
}
Expand Down
3 changes: 2 additions & 1 deletion core-it/src/test/java/apoc/core/it/CypherEnterpriseTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package apoc.core.it;

import apoc.util.Neo4jContainerExtension;
import apoc.util.TestUtil;
import org.assertj.core.api.Assertions;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -31,7 +32,7 @@ public class CypherEnterpriseTest {

@BeforeClass
public static void beforeAll() {
neo4jContainer = createEnterpriseDB(List.of(ApocPackage.CORE), true);
neo4jContainer = createEnterpriseDB(List.of(ApocPackage.CORE), !TestUtil.isRunningInCI());
neo4jContainer.start();
session = neo4jContainer.getSession();
}
Expand Down
21 changes: 6 additions & 15 deletions core-it/src/test/java/apoc/core/it/ExportCsvIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
import static apoc.util.TestUtil.isRunningInCI;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

/**
* @author as
Expand All @@ -51,25 +48,19 @@ public class ExportCsvIT {

@BeforeClass
public static void beforeAll() {
assumeFalse(isRunningInCI());
TestUtil.ignoreException(() -> {
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), true);
neo4jContainer.start();
}, Exception.class);
assumeNotNull(neo4jContainer);
assumeTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !isRunningInCI());
neo4jContainer.start();
session = neo4jContainer.getSession();
}

@AfterClass
public static void afterAll() throws IOException, InterruptedException {
if (neo4jContainer != null && neo4jContainer.isRunning()) {
neo4jContainer.close();
}
public static void afterAll() {
session.close();
neo4jContainer.close();
}

@Test
public void testExportQueryCsvIssue1188() throws Exception {
public void testExportQueryCsvIssue1188() {
String copyright = "\n" +
"(c) 2018 Hovsepian, Albanese, et al. \"\"ASCB(r),\"\" \"\"The American Society for Cell Biology(r),\"\" and \"\"Molecular Biology of the Cell(r)\"\" are registered trademarks of The American Society for Cell Biology.\n" +
"2018\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package apoc.core.it;

import apoc.util.Neo4jContainerExtension;
import apoc.util.TestContainerUtil;
import apoc.util.TestUtil;
import apoc.util.Util;
import org.hamcrest.MatcherAssert;
Expand All @@ -37,13 +36,9 @@
import static apoc.export.cypher.ExportCypherTest.ExportCypherResults.*;
import static apoc.util.MapUtil.map;
import static apoc.util.TestContainerUtil.*;
import static apoc.util.TestUtil.isRunningInCI;
import static apoc.util.TestUtil.readFileToString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

/**
* @author as
Expand All @@ -56,23 +51,15 @@ public class ExportCypherEnterpriseFeaturesTest {

@BeforeClass
public static void beforeAll() {
assumeFalse(isRunningInCI());
TestUtil.ignoreException(() -> {
// We build the project, the artifact will be placed into ./build/libs
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI())
.withInitScript("init_neo4j_export_csv.cypher");
neo4jContainer.start();
}, Exception.class);
assumeNotNull(neo4jContainer);
assumeTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
neo4jContainer = createEnterpriseDB(List.of(ApocPackage.CORE), !TestUtil.isRunningInCI()).withInitScript("init_neo4j_export_csv.cypher");
neo4jContainer.start();
session = neo4jContainer.getSession();
}

@AfterClass
public static void afterAll() {
if (neo4jContainer != null && neo4jContainer.isRunning()) {
neo4jContainer.close();
}
session.close();
neo4jContainer.close();
}

private static void beforeTwoLabelsWithOneCompoundConstraintEach() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@
import static apoc.refactor.GraphRefactoringTest.EXTRACT_QUERY;
import static apoc.util.TestContainerUtil.createEnterpriseDB;
import static apoc.util.TestContainerUtil.testCall;
import static apoc.util.TestUtil.isRunningInCI;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

public class GraphRefactoringEnterpriseTest {
private static final String CREATE_REL_FOR_EXTRACT_NODE = "CREATE (:Start)-[r:TO_MOVE {name: 'foobar', surname: 'baz'}]->(:End)";
Expand All @@ -49,22 +45,15 @@ public class GraphRefactoringEnterpriseTest {

@BeforeClass
public static void beforeAll() {
assumeFalse(isRunningInCI());
TestUtil.ignoreException(() -> {
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), true);
neo4jContainer.start();
}, Exception.class);
assumeNotNull(neo4jContainer);
assumeTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI());
neo4jContainer.start();
session = neo4jContainer.getSession();
}

@AfterClass
public static void afterAll() {
if (neo4jContainer != null && neo4jContainer.isRunning()) {
session.close();
neo4jContainer.close();
}
session.close();
neo4jContainer.close();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import apoc.util.CompressionAlgo;
import apoc.util.Neo4jContainerExtension;
import apoc.util.TestContainerUtil;
import apoc.util.TestUtil;
import org.apache.commons.io.FileUtils;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
Expand Down Expand Up @@ -65,7 +66,7 @@ public class LoadCoreEnterpriseTest {
}

private static Neo4jContainerExtension createNeo4jWithMaxCompressionRatio(int ratio) {
Neo4jContainerExtension container = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), true)
Neo4jContainerExtension container = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI())
.withNeo4jConfig("dbms.memory.heap.max_size", "1GB")
.withEnv(APOC_MAX_DECOMPRESSION_RATIO, String.valueOf(ratio));
container.start();
Expand Down
13 changes: 2 additions & 11 deletions core-it/src/test/java/apoc/core/it/MetaEnterpriseFeaturesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@

import static apoc.util.TestContainerUtil.createEnterpriseDB;
import static apoc.util.TestContainerUtil.testResult;
import static apoc.util.TestUtil.isRunningInCI;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;

/**
* @author as
Expand All @@ -52,21 +48,16 @@ public class MetaEnterpriseFeaturesTest {

@BeforeClass
public static void beforeAll() {
assumeFalse(isRunningInCI());
// We build the project, the artifact will be placed into ./build/libs
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI());
neo4jContainer.start();
assumeNotNull(neo4jContainer);
assumeTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning());
session = neo4jContainer.getSession();
}

@AfterClass
public static void afterAll() {
if (neo4jContainer != null && neo4jContainer.isRunning()) {
session.close();
neo4jContainer.close();
}
session.close();
neo4jContainer.close();
}

public static boolean hasRecordMatching(List<Map<String,Object>> records, Predicate<Map<String,Object>> predicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import apoc.util.Neo4jContainerExtension;
import apoc.util.TestContainerUtil;
import apoc.util.TestUtil;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class SchemasEnterpriseFeaturesTest {

@BeforeClass
public static void beforeAll() {
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), true);
neo4jContainer = createEnterpriseDB(List.of(TestContainerUtil.ApocPackage.CORE), !TestUtil.isRunningInCI());
neo4jContainer.start();
session = neo4jContainer.getSession();
}
Expand Down
Loading

0 comments on commit 03f19a1

Please sign in to comment.