Skip to content

Commit

Permalink
[gRNAet7B] Changes after core part merge
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Jan 9, 2023
1 parent 8d12d51 commit fe96a33
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[submodule "apoc-core"]
path = apoc-core
url = https://github.com/neo4j/apoc
branch = dev-fix-trigger-procedures
branch = dev
[submodule "apoc"]
path = apoc
url = https://[email protected]/neo4j/apoc.git
1 change: 1 addition & 0 deletions apoc
Submodule apoc added at c57579
2 changes: 1 addition & 1 deletion apoc-core
Submodule apoc-core updated 261 files
32 changes: 24 additions & 8 deletions extended/src/test/java/apoc/trigger/TriggerClusterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.neo4j.driver.types.Node;
import org.neo4j.driver.Session;
Expand All @@ -17,13 +16,16 @@
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME;
import static org.neo4j.configuration.GraphDatabaseSettings.SYSTEM_DATABASE_NAME;
import static org.neo4j.driver.SessionConfig.forDatabase;
import static org.neo4j.test.assertion.Assert.assertEventually;

public class TriggerClusterTest {

private static final String DB_FOO = "foo";
private static TestcontainersCausalCluster cluster;

@BeforeClass
Expand All @@ -48,7 +50,6 @@ public void before() {
cluster.getSession().run("MATCH (n) DETACH DELETE n");
}

@Ignore
@Test
public void testTimeStampTriggerForUpdatedProperties() throws Exception {
cluster.getSession().run("CALL apoc.trigger.add('timestamp','UNWIND apoc.trigger.nodesByLabel($assignedNodeProperties,null) AS n SET n.ts = timestamp()',{})");
Expand All @@ -58,7 +59,6 @@ public void testTimeStampTriggerForUpdatedProperties() throws Exception {
});
}

@Ignore
@Test
public void testReplication() throws Exception {
cluster.getSession().run("CALL apoc.trigger.add('timestamp','UNWIND apoc.trigger.nodesByLabel($assignedNodeProperties,null) AS n SET n.ts = timestamp()',{})");
Expand All @@ -68,7 +68,6 @@ public void testReplication() throws Exception {
(value) -> "timestamp".equals(value), 30, TimeUnit.SECONDS);
}

@Ignore
@Test
public void testLowerCaseName() throws Exception {
cluster.getSession().run("create constraint on (p:Person) assert p.id is unique");
Expand All @@ -80,7 +79,6 @@ public void testLowerCaseName() throws Exception {
});
}

@Ignore
@Test
public void testSetLabels() throws Exception {
cluster.getSession().run("CREATE (f {name:'John Doe'})");
Expand All @@ -95,7 +93,6 @@ public void testSetLabels() throws Exception {
assertEquals(1L, count);
}

@Ignore
@Test
public void testTxIdAfterAsync() throws Exception {
cluster.getSession().run("CALL apoc.trigger.add('triggerTest','UNWIND apoc.trigger.propertiesByKey($assignedNodeProperties, \"_executed\") as prop " +
Expand All @@ -109,6 +106,7 @@ public void testTxIdAfterAsync() throws Exception {
(value) -> value == 2L, 30, TimeUnit.SECONDS);
}


//
// test cases duplicated, regarding new procedures
//
Expand All @@ -129,7 +127,6 @@ public void testTimeStampTriggerForUpdatedPropertiesNewProcedures() throws Excep
}
}


@Test
public void testReplicationNewProcedures() throws Exception {
try (final Session session = cluster.getDriver().session(forDatabase(SYSTEM_DATABASE_NAME))) {
Expand All @@ -138,7 +135,7 @@ public void testReplicationNewProcedures() throws Exception {
// Test that the trigger is present in another instance
awaitProcedureInstalled(cluster.getDriver().session(), "timestamp");
}

@Test
public void testLowerCaseNameNewProcedures() {
final String name = "lowercase";
Expand Down Expand Up @@ -209,4 +206,23 @@ private static void awaitProcedureInstalled(Session session, String name) {
name::equals,
30, TimeUnit.SECONDS);
}

@Test
public void testTriggerCreatedInCorrectDatabase() {
final String name = "testDatabase";
try (final Session session = cluster.getDriver().session(forDatabase(SYSTEM_DATABASE_NAME))) {
session.run("CALL apoc.trigger.install($dbName, $name, 'RETURN 1', " +
"{phase:'afterAsync'})",
Map.of("dbName", DB_FOO, "name", name));
}
try (final Session session = cluster.getDriver().session(forDatabase(DB_FOO))) {
awaitProcedureInstalled(session, name);
}
try (final Session session = cluster.getDriver().session(forDatabase(DEFAULT_DATABASE_NAME))) {
TestContainerUtil.testResult(session, "CALL apoc.trigger.list() " +
"YIELD name WHERE name = $name RETURN name",
Map.of("name", name),
res -> assertFalse(res.hasNext()));
}
}
}

0 comments on commit fe96a33

Please sign in to comment.